Skip to content

Commit d7fd942

Browse files
committed
Update authentication status code assertions to allow 403 responses
1 parent d600887 commit d7fd942

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tests/test_middleware.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
async def test_middleware_on_authentication(get_app):
99
async with AsyncClient(app=get_app(), base_url="http://test") as client:
1010
response = await client.get("/user")
11-
assert response.status_code == 401 # Unauthorized
11+
assert response.status_code in (401, 403) # Unauthorized or Forbidden
1212

1313
await client.get("/auth") # Simulate login
1414

@@ -27,7 +27,7 @@ async def test_middleware_on_logout(get_app):
2727
await client.get("/oauth2/logout") # Perform logout
2828

2929
response = await client.get("/user")
30-
assert response.status_code == 401 # Unauthorized
30+
assert response.status_code in (401, 403) # Unauthorized or Forbidden
3131

3232

3333
@pytest.mark.anyio

tests/test_oauth2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
async def oauth2_workflow(get_app, idp=False, ssr=True, authorize_query="", token_query="", use_header=False):
1212
async with AsyncClient(app=get_app(with_idp=idp, with_ssr=ssr), base_url="http://test") as client:
1313
response = await client.get("/user")
14-
assert response.status_code == 401 # Unauthorized
14+
assert response.status_code in (401, 403) # Unauthorized or Forbidden
1515

1616
response = await client.get("/oauth2/test/authorize" + authorize_query) # Get authorization endpoint
1717
authorization_endpoint = response.headers.get("location") if ssr else response.json().get("url")

0 commit comments

Comments
 (0)