@@ -126,7 +126,8 @@ async def test_init(self, oauth_provider, client_metadata, mock_storage):
126126 assert oauth_provider .storage == mock_storage
127127 assert oauth_provider .timeout == 300.0
128128
129- def test_generate_code_verifier (self , oauth_provider ):
129+ @pytest .mark .anyio
130+ async def test_generate_code_verifier (self , oauth_provider ):
130131 """Test PKCE code verifier generation."""
131132 verifier = oauth_provider ._generate_code_verifier ()
132133
@@ -143,7 +144,8 @@ def test_generate_code_verifier(self, oauth_provider):
143144 verifiers = {oauth_provider ._generate_code_verifier () for _ in range (10 )}
144145 assert len (verifiers ) == 10
145146
146- def test_generate_code_challenge (self , oauth_provider ):
147+ @pytest .mark .anyio
148+ async def test_generate_code_challenge (self , oauth_provider ):
147149 """Test PKCE code challenge generation."""
148150 verifier = "test_code_verifier_123"
149151 challenge = oauth_provider ._generate_code_challenge (verifier )
@@ -161,7 +163,8 @@ def test_generate_code_challenge(self, oauth_provider):
161163 assert "+" not in challenge
162164 assert "/" not in challenge
163165
164- def test_get_authorization_base_url (self , oauth_provider ):
166+ @pytest .mark .anyio
167+ async def test_get_authorization_base_url (self , oauth_provider ):
165168 """Test authorization base URL extraction."""
166169 # Test with path
167170 assert (
@@ -348,11 +351,13 @@ async def test_register_oauth_client_failure(self, oauth_provider):
348351 None ,
349352 )
350353
351- def test_has_valid_token_no_token (self , oauth_provider ):
354+ @pytest .mark .anyio
355+ async def test_has_valid_token_no_token (self , oauth_provider ):
352356 """Test token validation with no token."""
353357 assert not oauth_provider ._has_valid_token ()
354358
355- def test_has_valid_token_valid (self , oauth_provider , oauth_token ):
359+ @pytest .mark .anyio
360+ async def test_has_valid_token_valid (self , oauth_provider , oauth_token ):
356361 """Test token validation with valid token."""
357362 oauth_provider ._current_tokens = oauth_token
358363 oauth_provider ._token_expiry_time = time .time () + 3600 # Future expiry
@@ -756,7 +761,8 @@ async def test_async_auth_flow_no_token(self, oauth_provider):
756761 # No Authorization header should be added if no token
757762 assert "Authorization" not in updated_request .headers
758763
759- def test_scope_priority_client_metadata_first (
764+ @pytest .mark .anyio
765+ async def test_scope_priority_client_metadata_first (
760766 self , oauth_provider , oauth_client_info
761767 ):
762768 """Test that client metadata scope takes priority."""
@@ -785,7 +791,8 @@ def test_scope_priority_client_metadata_first(
785791
786792 assert auth_params ["scope" ] == "read write"
787793
788- def test_scope_priority_no_client_metadata_scope (
794+ @pytest .mark .anyio
795+ async def test_scope_priority_no_client_metadata_scope (
789796 self , oauth_provider , oauth_client_info
790797 ):
791798 """Test that no scope parameter is set when client metadata has no scope."""
@@ -968,18 +975,30 @@ def test_build_metadata(
968975 revocation_options = RevocationOptions (enabled = True ),
969976 )
970977
971- assert metadata == snapshot (
972- OAuthMetadata (
973- issuer = AnyHttpUrl (issuer_url ),
974- authorization_endpoint = AnyHttpUrl (authorization_endpoint ),
975- token_endpoint = AnyHttpUrl (token_endpoint ),
976- registration_endpoint = AnyHttpUrl (registration_endpoint ),
977- scopes_supported = ["read" , "write" , "admin" ],
978- grant_types_supported = ["authorization_code" , "refresh_token" ],
979- token_endpoint_auth_methods_supported = ["client_secret_post" ],
980- service_documentation = AnyHttpUrl (service_documentation_url ),
981- revocation_endpoint = AnyHttpUrl (revocation_endpoint ),
982- revocation_endpoint_auth_methods_supported = ["client_secret_post" ],
983- code_challenge_methods_supported = ["S256" ],
984- )
978+ # Compare individual attributes instead of using snapshot
979+ expected = OAuthMetadata (
980+ issuer = AnyHttpUrl (issuer_url ),
981+ authorization_endpoint = AnyHttpUrl (authorization_endpoint ),
982+ token_endpoint = AnyHttpUrl (token_endpoint ),
983+ registration_endpoint = AnyHttpUrl (registration_endpoint ),
984+ scopes_supported = ["read" , "write" , "admin" ],
985+ grant_types_supported = ["authorization_code" , "refresh_token" ],
986+ token_endpoint_auth_methods_supported = ["client_secret_post" ],
987+ service_documentation = AnyHttpUrl (service_documentation_url ),
988+ revocation_endpoint = AnyHttpUrl (revocation_endpoint ),
989+ revocation_endpoint_auth_methods_supported = ["client_secret_post" ],
990+ code_challenge_methods_supported = ["S256" ],
985991 )
992+
993+ # Compare each field individually
994+ assert str (metadata .issuer ) == str (expected .issuer )
995+ assert str (metadata .authorization_endpoint ) == str (expected .authorization_endpoint )
996+ assert str (metadata .token_endpoint ) == str (expected .token_endpoint )
997+ assert str (metadata .registration_endpoint ) == str (expected .registration_endpoint )
998+ assert metadata .scopes_supported == expected .scopes_supported
999+ assert metadata .grant_types_supported == expected .grant_types_supported
1000+ assert metadata .token_endpoint_auth_methods_supported == expected .token_endpoint_auth_methods_supported
1001+ assert str (metadata .service_documentation ) == str (expected .service_documentation )
1002+ assert str (metadata .revocation_endpoint ) == str (expected .revocation_endpoint )
1003+ assert metadata .revocation_endpoint_auth_methods_supported == expected .revocation_endpoint_auth_methods_supported
1004+ assert metadata .code_challenge_methods_supported == expected .code_challenge_methods_supported
0 commit comments