Skip to content

Commit 310d939

Browse files
committed
test(auth): add coverage tests to satisfy 100% gate
1 parent 76b1d1e commit 310d939

15 files changed

+2151
-0
lines changed

tests/client/auth/test_dpop.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import base64
44
import hashlib
5+
from typing import Any, cast
56

67
import jwt
78
import pytest
@@ -117,3 +118,13 @@ def test_dpop_key_pair_generate_rs256_custom_key_size() -> None:
117118
def test_dpop_key_pair_generate_rs256_rejects_small_key_size() -> None:
118119
with pytest.raises(ValueError, match="RSA key size must be at least 2048"):
119120
DPoPKeyPair.generate("RS256", rsa_key_size=1024)
121+
122+
123+
def test_dpop_key_pair_generate_rejects_unsupported_algorithm() -> None:
124+
with pytest.raises(ValueError, match="Unsupported algorithm"):
125+
DPoPKeyPair.generate(cast(Any, "HS256"))
126+
127+
128+
def test_compute_jwk_thumbprint_rejects_unsupported_key_type() -> None:
129+
with pytest.raises(ValueError, match="Unsupported key type"):
130+
compute_jwk_thumbprint({"kty": "oct"})

tests/client/auth/test_dpop_integration.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ async def set_tokens(self, tokens: AuthCredentials | OAuthToken) -> None:
121121
self._tokens = tokens
122122

123123

124+
@pytest.mark.anyio
125+
async def test_mock_storage_set_tokens_is_exercised_for_coverage() -> None:
126+
storage = MockStorage()
127+
token = OAuthToken(access_token="at", token_type="Bearer", expires_in=3600)
128+
await storage.set_tokens(token)
129+
assert await storage.get_tokens() is token
130+
131+
124132
@pytest.mark.anyio
125133
async def test_multi_protocol_provider_dpop_header_injection(
126134
client_metadata: OAuthClientMetadata,

0 commit comments

Comments
 (0)