fix: runtime errors in api server

This commit is contained in:
sriram veeraghanta
2025-09-30 02:02:29 +05:30
parent 65b1004659
commit ae084e197b
+9 -21
View File
@@ -19,9 +19,7 @@ class TestAuthSmoke:
# For bad credentials, any of these status codes would be valid
# The test shouldn't be brittle to minor implementation changes
assert (
response.status_code != 500
), "Authentication should not cause server errors"
assert response.status_code != 500, "Authentication should not cause server errors"
assert response.status_code != 404, "Authentication endpoint should exist"
if response.status_code == 200:
@@ -51,8 +49,8 @@ class TestAuthSmoke:
)
# Successful auth should not be a client error or server error
assert (
response.status_code not in range(400, 600)
assert response.status_code not in range(
400, 600
), f"Authentication with valid credentials failed with status {response.status_code}"
# Specific validation based on response type
@@ -70,27 +68,17 @@ class TestAuthSmoke:
data = response.json()
# If it's a token response
if "access_token" in data:
<<<<<<< HEAD
assert "refresh_token" in data, "JWT auth should return both access and refresh tokens"
=======
<<<<<<< HEAD
assert "refresh_token" in data, "JWT auth should return both access and refresh tokens"
=======
assert (
"refresh_token" in data
), "JWT auth should return both access and refresh tokens"
>>>>>>> d63015f53db1ab1962ff810ae82dcfb1a5478140
>>>>>>> ebeac413faf27b87803939d3aa3829b38a66e19c
# If it's a user session response
elif "user" in data:
assert "is_authenticated" in data and data["is_authenticated"], (
"User session response should indicate authentication"
)
assert (
"is_authenticated" in data and data["is_authenticated"]
), "User session response should indicate authentication"
# Otherwise it should at least indicate success
else:
assert not any(error_key in data for error_key in ["error", "error_code", "detail"]), (
"Success response should not contain error keys"
)
assert not any(
error_key in data for error_key in ["error", "error_code", "detail"]
), "Success response should not contain error keys"
except ValueError:
# Non-JSON is acceptable if it's a redirect or HTML response
pass