Linted and formatted all files
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import pytest
|
||||
from fastapi import HTTPException
|
||||
|
||||
from app.auth.mock_auth import mock_get_user_from_token, mock_initiate_auth
|
||||
from app.models.auth import CognitoUser
|
||||
|
||||
|
||||
def test_mock_get_user_from_token_success():
|
||||
"""Test successful token validation returns expected user"""
|
||||
user = mock_get_user_from_token("testuser")
|
||||
@@ -10,27 +12,30 @@ def test_mock_get_user_from_token_success():
|
||||
assert user.username == "testuser"
|
||||
assert user.roles == ["admin"]
|
||||
|
||||
|
||||
def test_mock_get_user_from_token_invalid():
|
||||
"""Test invalid token raises expected exception"""
|
||||
with pytest.raises(HTTPException) as exc_info:
|
||||
mock_get_user_from_token("invalid_token")
|
||||
|
||||
|
||||
assert exc_info.value.status_code == 401
|
||||
assert exc_info.value.detail == "Invalid mock token - use 'testuser'"
|
||||
|
||||
|
||||
def test_mock_initiate_auth():
|
||||
"""Test mock authentication returns expected token response"""
|
||||
result = mock_initiate_auth("any_user", "any_password")
|
||||
|
||||
|
||||
assert isinstance(result, dict)
|
||||
assert result["AccessToken"] == "testuser"
|
||||
assert result["ExpiresIn"] == 3600
|
||||
assert result["TokenType"] == "Bearer"
|
||||
|
||||
|
||||
def test_mock_initiate_auth_different_credentials():
|
||||
"""Test mock authentication works with any credentials"""
|
||||
result1 = mock_initiate_auth("user1", "pass1")
|
||||
result2 = mock_initiate_auth("user2", "pass2")
|
||||
|
||||
|
||||
# Should return same mock token regardless of credentials
|
||||
assert result1 == result2
|
||||
assert result1 == result2
|
||||
|
||||
Reference in New Issue
Block a user