Fix auth test assertions to match updated error messages

Update test assertions in test_auth.py and test_auth_github.py to expect
"Invalid Authorization header format" instead of "Missing or invalid
Authorization header" to align with the error message changes made in
the auth implementation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ehhuang 2025-07-03 10:26:51 -07:00 committed by Eric Huang
parent d07351bfcd
commit 409996695b
3 changed files with 5 additions and 5 deletions

View file

@ -323,7 +323,7 @@ class GitHubTokenAuthProvider(AuthProvider):
async def validate_token(self, token: str, scope: dict | None = None) -> User: async def validate_token(self, token: str, scope: dict | None = None) -> User:
"""Validate a GitHub token by calling the GitHub API. """Validate a GitHub token by calling the GitHub API.
This validates tokens issued by GitHub (personal access tokens or OAuth tokens). This validates tokens issued by GitHub (personal access tokens or OAuth tokens).
""" """
try: try:

View file

@ -149,7 +149,7 @@ def test_missing_auth_header(http_client):
def test_invalid_auth_header_format(http_client): def test_invalid_auth_header_format(http_client):
response = http_client.get("/test", headers={"Authorization": "InvalidFormat token123"}) response = http_client.get("/test", headers={"Authorization": "InvalidFormat token123"})
assert response.status_code == 401 assert response.status_code == 401
assert "Missing or invalid Authorization header" in response.json()["error"]["message"] assert "Invalid Authorization header format" in response.json()["error"]["message"]
@patch("httpx.AsyncClient.post", new=mock_post_success) @patch("httpx.AsyncClient.post", new=mock_post_success)
@ -277,7 +277,7 @@ def test_missing_auth_header_oauth2(oauth2_client):
def test_invalid_auth_header_format_oauth2(oauth2_client): def test_invalid_auth_header_format_oauth2(oauth2_client):
response = oauth2_client.get("/test", headers={"Authorization": "InvalidFormat token123"}) response = oauth2_client.get("/test", headers={"Authorization": "InvalidFormat token123"})
assert response.status_code == 401 assert response.status_code == 401
assert "Missing or invalid Authorization header" in response.json()["error"]["message"] assert "Invalid Authorization header format" in response.json()["error"]["message"]
async def mock_jwks_response(*args, **kwargs): async def mock_jwks_response(*args, **kwargs):
@ -502,7 +502,7 @@ def test_missing_auth_header_introspection(introspection_client):
def test_invalid_auth_header_format_introspection(introspection_client): def test_invalid_auth_header_format_introspection(introspection_client):
response = introspection_client.get("/test", headers={"Authorization": "InvalidFormat token123"}) response = introspection_client.get("/test", headers={"Authorization": "InvalidFormat token123"})
assert response.status_code == 401 assert response.status_code == 401
assert "Missing or invalid Authorization header" in response.json()["error"]["message"] assert "Invalid Authorization header format" in response.json()["error"]["message"]
async def mock_introspection_active(*args, **kwargs): async def mock_introspection_active(*args, **kwargs):

View file

@ -72,7 +72,7 @@ def test_authenticated_endpoint_with_invalid_bearer_format(github_token_client):
"""Test accessing protected endpoint with invalid bearer format""" """Test accessing protected endpoint with invalid bearer format"""
response = github_token_client.get("/test", headers={"Authorization": "InvalidFormat token123"}) response = github_token_client.get("/test", headers={"Authorization": "InvalidFormat token123"})
assert response.status_code == 401 assert response.status_code == 401
assert "Missing or invalid Authorization header" in response.json()["error"]["message"] assert "Invalid Authorization header format" in response.json()["error"]["message"]
@patch("llama_stack.distribution.server.auth_providers.httpx.AsyncClient") @patch("llama_stack.distribution.server.auth_providers.httpx.AsyncClient")