@@ -2798,26 +2798,37 @@ def test_union_scopes(previous: str | None, new: str | None, expected: str | Non
27982798
27992799def test_credentials_match_issuer_same_issuer ():
28002800 info = OAuthClientInformationFull (client_id = "c" , redirect_uris = [AnyUrl ("http://localhost/cb" )], issuer = "https://as" )
2801- assert credentials_match_issuer (info , "https://as" ) is True
2801+ assert credentials_match_issuer (info , "https://as" , None ) is True
28022802
28032803
28042804def test_credentials_match_issuer_different_issuer ():
28052805 info = OAuthClientInformationFull (client_id = "c" , redirect_uris = [AnyUrl ("http://localhost/cb" )], issuer = "https://as" )
2806- assert credentials_match_issuer (info , "https://other" ) is False
2806+ assert credentials_match_issuer (info , "https://other" , None ) is False
28072807
28082808
28092809def test_credentials_match_issuer_no_recorded_issuer_is_left_alone ():
28102810 """Credentials with no bound issuer (pre-registered / legacy) carry no binding to enforce."""
28112811 info = OAuthClientInformationFull (client_id = "c" , redirect_uris = [AnyUrl ("http://localhost/cb" )])
2812- assert credentials_match_issuer (info , "https://as" ) is True
2812+ assert credentials_match_issuer (info , "https://as" , None ) is True
28132813
28142814
28152815def test_credentials_match_issuer_cimd_is_portable ():
2816- """A URL-based client_id (CIMD) is portable across authorization servers."""
2816+ """A client_id equal to the configured client_metadata_url (CIMD) is portable across servers."""
2817+ cimd_url = "https://client.example/metadata.json"
28172818 info = OAuthClientInformationFull (
2818- client_id = "https://client.example/metadata.json" ,
2819+ client_id = cimd_url ,
28192820 redirect_uris = [AnyUrl ("http://localhost/cb" )],
28202821 token_endpoint_auth_method = "none" ,
28212822 issuer = "https://as" ,
28222823 )
2823- assert credentials_match_issuer (info , "https://other" ) is True
2824+ assert credentials_match_issuer (info , "https://other" , cimd_url ) is True
2825+
2826+
2827+ def test_credentials_match_issuer_url_shaped_dcr_id_is_not_portable ():
2828+ """A URL-shaped client_id from DCR (not the configured CIMD URL) stays bound to its issuer."""
2829+ info = OAuthClientInformationFull (
2830+ client_id = "https://as.example.com/clients/123" ,
2831+ redirect_uris = [AnyUrl ("http://localhost/cb" )],
2832+ issuer = "https://as.example.com" ,
2833+ )
2834+ assert credentials_match_issuer (info , "https://other" , "https://client.example/metadata.json" ) is False
0 commit comments