fix(test): fix task __wrapped__ calls, auth imports, mock chains, async markers, and rate limit mock
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -64,6 +64,7 @@ class TestOAuthLoginFlow:
|
||||
class TestOAuthCallback:
|
||||
"""Test OAuth callback handling."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_oauth_callback_with_valid_token(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient, test_user_info: dict
|
||||
@@ -86,6 +87,7 @@ class TestOAuthCallback:
|
||||
# Should redirect after successful login
|
||||
assert response.status_code == 302
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_oauth_callback_stores_user_in_session(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient, test_user_info: dict
|
||||
@@ -108,6 +110,7 @@ class TestOAuthCallback:
|
||||
# Should set session cookie
|
||||
assert "set-cookie" in response.headers or response.status_code == 302
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_oauth_callback_with_admin_user(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient
|
||||
@@ -131,6 +134,7 @@ class TestOAuthCallback:
|
||||
# Should successfully authenticate
|
||||
assert response.status_code == 302
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_oauth_callback_rejects_non_admin(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient
|
||||
@@ -160,6 +164,7 @@ class TestOAuthCallback:
|
||||
class TestOAuthSessionManagement:
|
||||
"""Test session management with OAuth authentication."""
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_authenticated_user_can_access_protected_routes(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient, test_user_info: dict
|
||||
@@ -192,6 +197,7 @@ class TestOAuthSessionManagement:
|
||||
if response.status_code == 302:
|
||||
assert "/login" in response.headers.get("location", "")
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_logout_clears_session(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient, test_user_info: dict
|
||||
@@ -226,6 +232,7 @@ class TestOAuthErrorHandling:
|
||||
# Should handle error gracefully
|
||||
assert response.status_code in [302, 400]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_oauth_callback_with_invalid_token(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient
|
||||
@@ -244,6 +251,7 @@ class TestOAuthErrorHandling:
|
||||
location = response.headers.get("location", "")
|
||||
assert "error" in location.lower() or "login" in location.lower()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@patch("app.auth.oauth.authentik.authorize_access_token")
|
||||
async def test_oauth_callback_without_userinfo(
|
||||
self, mock_authorize, oauth_enabled_app: TestClient
|
||||
|
||||
Reference in New Issue
Block a user