@@ -121,6 +121,43 @@ def test_authorization_server_metadata_urls_for_path_issuer
121121 assert_includes ( urls , "https://auth.example.com/tenant1/.well-known/openid-configuration" )
122122 end
123123
124+ # Per SEP-2351, MCP explicitly uses the RFC 8414 default `oauth-authorization-server` well-known URI suffix
125+ # and defines no application-specific suffix. The first probed candidate for a root issuer must be exactly
126+ # that default suffix.
127+ def test_authorization_server_metadata_urls_probe_rfc8414_default_suffix_first
128+ urls = Discovery . authorization_server_metadata_urls ( "https://auth.example.com" )
129+
130+ assert_equal ( "https://auth.example.com/.well-known/oauth-authorization-server" , urls . first )
131+ end
132+
133+ def test_authorization_server_metadata_urls_use_only_registered_well_known_suffixes
134+ root_urls = Discovery . authorization_server_metadata_urls ( "https://auth.example.com" )
135+ path_urls = Discovery . authorization_server_metadata_urls ( "https://auth.example.com/tenant1" )
136+
137+ ( root_urls + path_urls ) . each do |url |
138+ suffix = url [ %r{/\. well-known/([^/]+)} , 1 ]
139+
140+ assert_includes (
141+ [ "oauth-authorization-server" , "openid-configuration" ] , suffix , "unexpected well-known suffix in #{ url } "
142+ )
143+ end
144+ end
145+
146+ def test_authorization_server_metadata_urls_put_path_inserted_oauth_candidate_first_for_path_issuer
147+ urls = Discovery . authorization_server_metadata_urls ( "https://auth.example.com/tenant1" )
148+
149+ assert_equal ( "https://auth.example.com/.well-known/oauth-authorization-server/tenant1" , urls . first )
150+ end
151+
152+ def test_authorization_server_metadata_urls_treat_trailing_slash_issuer_as_root
153+ urls = Discovery . authorization_server_metadata_urls ( "https://auth.example.com/" )
154+
155+ assert_equal (
156+ [ "https://auth.example.com/.well-known/oauth-authorization-server" , "https://auth.example.com/.well-known/openid-configuration" ] ,
157+ urls ,
158+ )
159+ end
160+
124161 def test_canonicalize_url_normalizes_scheme_host_port_and_path
125162 assert_equal (
126163 "https://srv.example.com/mcp" ,
0 commit comments