Skip to content

Commit

Permalink
test: fastapi and flask authz middleware logger init
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Jul 24, 2023
1 parent 1b4d0d0 commit 595f4cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/test_platform_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,12 @@ def _expect_error(r: HttpxResponse, code: int, msg: str):
assert data["errors"][0]["message"] == msg


def test_fastapi_middleware_init_logger():
inst = FastApiAuthMiddleware(bento_authz_service_url="https://bento-auth.local")
inst.attach(FastAPI()) # should create a logger if not specified
assert inst._logger is not None


def test_fastapi_http_exception_404(test_client: TestClient):
_expect_error(test_client.get("/get-404"), 404, "Hello")

Expand Down
7 changes: 7 additions & 0 deletions tests/test_platform_flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ def auth_disabled_post_private():
# -----------------------------------------------------------------------------


def test_flask_middleware_init_logger():
inst = FlaskAuthMiddleware(bento_authz_service_url="https://bento-auth.local")
app = Flask(__name__)
inst.attach(app)
assert inst._logger == app.logger


def test_flask_errors(flask_client):
# non-existent endpoint

Expand Down

0 comments on commit 595f4cc

Please sign in to comment.