@@ -962,7 +962,7 @@ async def callback_handler() -> tuple[str, str | None]:
962
962
963
963
964
964
@pytest .fixture
965
- def client_metadata_no_scope ():
965
+ def client_metadata_no_scope () -> OAuthClientMetadata :
966
966
"""Client metadata without a predefined scope."""
967
967
return OAuthClientMetadata (
968
968
client_name = "Test Client" ,
@@ -974,8 +974,11 @@ def client_metadata_no_scope():
974
974
975
975
976
976
@pytest .fixture
977
- def oauth_provider_without_scope (client_metadata_no_scope , mock_storage ):
977
+ def oauth_provider_without_scope (
978
+ client_metadata_no_scope : OAuthClientMetadata , mock_storage : MockTokenStorage
979
+ ) -> OAuthClientProvider :
978
980
"""Create OAuth provider without predefined scope."""
981
+
979
982
async def redirect_handler (url : str ) -> None :
980
983
pass
981
984
@@ -995,7 +998,7 @@ class TestScopeHandlingPriority:
995
998
"""Test OAuth scope handling priority between PRM and auth metadata."""
996
999
997
1000
@pytest .mark .anyio
998
- async def test_prioritize_prm_scopes_over_oauth_metadata (self , oauth_provider_without_scope ):
1001
+ async def test_prioritize_prm_scopes_over_oauth_metadata (self , oauth_provider_without_scope : OAuthClientProvider ):
999
1002
"""Test that PRM scopes are prioritized over auth server metadata scopes."""
1000
1003
provider = oauth_provider_without_scope
1001
1004
@@ -1023,9 +1026,11 @@ async def test_prioritize_prm_scopes_over_oauth_metadata(self, oauth_provider_wi
1023
1026
1024
1027
# Verify that PRM scopes are used (not OAuth metadata scopes)
1025
1028
assert provider .context .client_metadata .scope == "resource:read resource:write"
1026
-
1029
+
1027
1030
@pytest .mark .anyio
1028
- async def test_fallback_to_oauth_metadata_scopes_when_no_prm_scopes (self , oauth_provider_without_scope ):
1031
+ async def test_fallback_to_oauth_metadata_scopes_when_no_prm_scopes (
1032
+ self , oauth_provider_without_scope : OAuthClientProvider
1033
+ ):
1029
1034
"""Test fallback to OAuth metadata scopes when PRM has no scopes."""
1030
1035
provider = oauth_provider_without_scope
1031
1036
@@ -1055,7 +1060,9 @@ async def test_fallback_to_oauth_metadata_scopes_when_no_prm_scopes(self, oauth_
1055
1060
assert provider .context .client_metadata .scope == "read write admin"
1056
1061
1057
1062
@pytest .mark .anyio
1058
- async def test_fallback_to_oauth_metadata_scopes_when_no_prm (self , oauth_provider_without_scope ):
1063
+ async def test_fallback_to_oauth_metadata_scopes_when_no_prm (
1064
+ self , oauth_provider_without_scope : OAuthClientProvider
1065
+ ):
1059
1066
"""Test fallback to OAuth metadata scopes when no PRM is available."""
1060
1067
provider = oauth_provider_without_scope
1061
1068
@@ -1080,7 +1087,7 @@ async def test_fallback_to_oauth_metadata_scopes_when_no_prm(self, oauth_provide
1080
1087
assert provider .context .client_metadata .scope == "read write admin"
1081
1088
1082
1089
@pytest .mark .anyio
1083
- async def test_no_scope_changes_when_both_missing (self , oauth_provider_without_scope ):
1090
+ async def test_no_scope_changes_when_both_missing (self , oauth_provider_without_scope : OAuthClientProvider ):
1084
1091
"""Test that no scope changes occur when both PRM and OAuth metadata lack scopes."""
1085
1092
provider = oauth_provider_without_scope
1086
1093
@@ -1110,12 +1117,14 @@ async def test_no_scope_changes_when_both_missing(self, oauth_provider_without_s
1110
1117
assert provider .context .client_metadata .scope is None
1111
1118
1112
1119
@pytest .mark .anyio
1113
- async def test_preserve_existing_client_scope (self , client_metadata_no_scope , mock_storage ):
1120
+ async def test_preserve_existing_client_scope (
1121
+ self , client_metadata_no_scope : OAuthClientMetadata , mock_storage : MockTokenStorage
1122
+ ):
1114
1123
"""Test that existing client scope is preserved regardless of metadata."""
1115
1124
# Create client with predefined scope
1116
1125
client_metadata = client_metadata_no_scope
1117
1126
client_metadata .scope = "predefined:scope"
1118
-
1127
+
1119
1128
# Create provider
1120
1129
async def redirect_handler (url : str ) -> None :
1121
1130
pass
@@ -1154,4 +1163,4 @@ async def callback_handler() -> tuple[str, str | None]:
1154
1163
await provider ._handle_oauth_metadata_response (oauth_metadata_response )
1155
1164
1156
1165
# Verify that predefined scope is preserved
1157
- assert provider .context .client_metadata .scope == "predefined:scope"
1166
+ assert provider .context .client_metadata .scope == "predefined:scope"
0 commit comments