Test rejecting an RPC with server middleware.
()
| 2111 | |
| 2112 | |
| 2113 | def test_middleware_reject(): |
| 2114 | """Test rejecting an RPC with server middleware.""" |
| 2115 | with HeaderFlightServer(middleware={ |
| 2116 | "test": SelectiveAuthServerMiddlewareFactory(), |
| 2117 | }) as server, \ |
| 2118 | FlightClient(('localhost', server.port)) as client: |
| 2119 | # The middleware allows this through without auth. |
| 2120 | with pytest.raises(pa.ArrowNotImplementedError): |
| 2121 | list(client.list_actions()) |
| 2122 | |
| 2123 | # But not anything else. |
| 2124 | with pytest.raises(flight.FlightUnauthenticatedError): |
| 2125 | list(client.do_action(flight.Action(b"", b""))) |
| 2126 | |
| 2127 | client = FlightClient( |
| 2128 | ('localhost', server.port), |
| 2129 | middleware=[SelectiveAuthClientMiddlewareFactory()] |
| 2130 | ) |
| 2131 | response = next(client.do_action(flight.Action(b"", b""))) |
| 2132 | assert b"password" == response.body.to_pybytes() |
| 2133 | |
| 2134 | |
| 2135 | def test_middleware_mapping(): |
nothing calls this directly
no test coverage detected