|
13 | 13 | from authlib.jose import JsonWebKey, JsonWebToken |
14 | 14 |
|
15 | 15 | from authentication.jwk_token import JwkTokenAuthDependency, _jwk_cache |
16 | | -from constants import DEFAULT_USER_NAME, DEFAULT_USER_UID, NO_USER_TOKEN |
17 | 16 | from models.config import JwkConfiguration, JwtConfiguration |
18 | 17 |
|
19 | 18 | TEST_USER_ID = "test-user-123" |
@@ -435,19 +434,16 @@ async def test_no_auth_header( |
435 | 434 | mocked_signing_keys_server: Any, |
436 | 435 | no_token_request: Request, |
437 | 436 | ) -> None: |
438 | | - """Test with no Authorization header.""" |
| 437 | + """Test with no Authorization header returns 401 Unauthorized.""" |
439 | 438 | _ = mocked_signing_keys_server |
440 | 439 |
|
441 | 440 | dependency = JwkTokenAuthDependency(default_jwk_configuration) |
442 | 441 |
|
443 | | - user_id, username, skip_userid_check, token_claims = await dependency( |
444 | | - no_token_request |
445 | | - ) |
| 442 | + with pytest.raises(HTTPException) as exc_info: |
| 443 | + await dependency(no_token_request) |
446 | 444 |
|
447 | | - assert user_id == DEFAULT_USER_UID |
448 | | - assert username == DEFAULT_USER_NAME |
449 | | - assert skip_userid_check is True |
450 | | - assert token_claims == NO_USER_TOKEN |
| 445 | + assert exc_info.value.status_code == 401 |
| 446 | + assert "No Authorization header found" in str(exc_info.value.detail) |
451 | 447 |
|
452 | 448 |
|
453 | 449 | async def test_no_bearer( |
|
0 commit comments