I can login test is now working

This commit is contained in:
2025-10-27 21:47:07 +01:00
parent 09d012d065
commit 3f3e3a6ae5
2 changed files with 21 additions and 9 deletions
+9 -6
View File
@@ -33,6 +33,8 @@ DEFAULT_SKIP_PATTERNS = [
'/logout',
]
http_client = httpx
def create_auth_beforeware(additional_patterns: Optional[List[str]] = None) -> Beforeware:
"""
@@ -174,7 +176,7 @@ def login_user(email: str, password: str) -> Optional[Dict[str, Any]]:
None if authentication fails
"""
try:
response = httpx.post(
response = http_client.post(
f"{API_BASE_URL}/auth/login",
data={"username": email, "password": password},
headers={"Content-Type": "application/x-www-form-urlencoded"},
@@ -200,6 +202,7 @@ def register_user(email: str, username: str, password: str) -> Optional[Dict[str
Args:
email: User email address
username: User name
password: User password
Returns:
@@ -207,9 +210,9 @@ def register_user(email: str, username: str, password: str) -> Optional[Dict[str
None if registration fails
"""
try:
response = httpx.post(
response = http_client.post(
f"{API_BASE_URL}/auth/register",
json={"email": email, "username": username, "password": password},
json={"email": email, "username": username, "password": password},
timeout=10.0
)
@@ -233,7 +236,7 @@ def refresh_access_token(refresh_token: str) -> Optional[Dict[str, Any]]:
None if refresh fails
"""
try:
response = httpx.post(
response = http_client.post(
f"{API_BASE_URL}/auth/refresh",
json={"refresh_token": refresh_token},
timeout=10.0
@@ -263,7 +266,7 @@ def get_user_info(access_token: str) -> Optional[Dict[str, Any]]:
None if request fails
"""
try:
response = httpx.get(
response = http_client.get(
f"{API_BASE_URL}/auth/me",
headers={"Authorization": f"Bearer {access_token}"},
timeout=10.0
@@ -288,7 +291,7 @@ def logout_user(refresh_token: str) -> bool:
True if logout successful, False otherwise
"""
try:
response = httpx.post(
response = http_client.post(
f"{API_BASE_URL}/auth/logout",
json={"refresh_token": refresh_token},
timeout=10.0