@@ -440,94 +440,6 @@ func TestGetProtectedResourceMetadata_Error(t *testing.T) {
440440 }
441441}
442442
443- func TestGetAuthServerMetadata (t * testing.T ) {
444- tests := []struct {
445- name string
446- issuerPath string
447- endpointConfig * oauthtest.MetadataEndpointConfig
448- wantFallback bool
449- }{
450- {
451- name : "OAuthEndpoint_Root" ,
452- issuerPath : "" ,
453- endpointConfig : & oauthtest.MetadataEndpointConfig {
454- ServeOAuthInsertedEndpoint : true ,
455- },
456- },
457- {
458- name : "OpenIDEndpoint_Root" ,
459- issuerPath : "" ,
460- endpointConfig : & oauthtest.MetadataEndpointConfig {
461- ServeOpenIDInsertedEndpoint : true ,
462- },
463- },
464- {
465- name : "OAuthEndpoint_Path" ,
466- issuerPath : "/oauth" ,
467- endpointConfig : & oauthtest.MetadataEndpointConfig {
468- ServeOAuthInsertedEndpoint : true ,
469- },
470- },
471- {
472- name : "OpenIDEndpoint_Path" ,
473- issuerPath : "/openid" ,
474- endpointConfig : & oauthtest.MetadataEndpointConfig {
475- ServeOpenIDInsertedEndpoint : true ,
476- },
477- },
478- {
479- name : "OpenIDAppendedEndpoint_Path" ,
480- issuerPath : "/openid" ,
481- endpointConfig : & oauthtest.MetadataEndpointConfig {
482- ServeOpenIDAppendedEndpoint : true ,
483- },
484- },
485- {
486- name : "NoMetadata" ,
487- issuerPath : "" ,
488- endpointConfig : & oauthtest.MetadataEndpointConfig {
489- // All metadata endpoints disabled.
490- ServeOAuthInsertedEndpoint : false ,
491- ServeOpenIDInsertedEndpoint : false ,
492- },
493- wantFallback : true ,
494- },
495- }
496-
497- for _ , tt := range tests {
498- t .Run (tt .name , func (t * testing.T ) {
499- s := oauthtest .NewFakeAuthorizationServer (oauthtest.Config {
500- IssuerPath : tt .issuerPath ,
501- MetadataEndpointConfig : tt .endpointConfig ,
502- })
503- s .Start (t )
504- issuerURL := s .URL () + tt .issuerPath
505-
506- got , err := GetAuthServerMetadata (t .Context (), issuerURL , http .DefaultClient )
507- if tt .wantFallback {
508- // When no metadata is found, GetAuthServerMetadata returns (nil, nil).
509- // The fallback logic is now inline in Authorize.
510- if err != nil {
511- t .Fatalf ("GetAuthServerMetadata() unexpected error = %v, want nil" , err )
512- }
513- if got != nil {
514- t .Fatal ("GetAuthServerMetadata() expected nil for no metadata, got metadata" )
515- }
516- return
517- }
518- if err != nil {
519- t .Fatalf ("GetAuthServerMetadata() error = %v, want nil" , err )
520- }
521- if got == nil {
522- t .Fatal ("GetAuthServerMetadata() got nil, want metadata" )
523- }
524- if got .Issuer != issuerURL {
525- t .Errorf ("GetAuthServerMetadata() issuer = %q, want %q" , got .Issuer , issuerURL )
526- }
527- })
528- }
529- }
530-
531443func TestSelectTokenAuthMethod (t * testing.T ) {
532444 tests := []struct {
533445 name string
@@ -632,15 +544,6 @@ func TestHandleRegistration(t *testing.T) {
632544 if err != nil {
633545 t .Fatalf ("GetAuthServerMetadata() unexpected error = %v" , err )
634546 }
635- if asm == nil {
636- // Fallback to predefined endpoints for testing
637- asm = & oauthex.AuthServerMeta {
638- Issuer : s .URL (),
639- AuthorizationEndpoint : s .URL () + "/authorize" ,
640- TokenEndpoint : s .URL () + "/token" ,
641- RegistrationEndpoint : s .URL () + "/register" ,
642- }
643- }
644547 got , err := handler .handleRegistration (t .Context (), asm )
645548 if err != nil {
646549 if ! tt .wantError {
@@ -689,15 +592,6 @@ func TestDynamicRegistration(t *testing.T) {
689592 if err != nil {
690593 t .Fatalf ("GetAuthServerMetadata() unexpected error = %v" , err )
691594 }
692- if asm == nil {
693- // Fallback to predefined endpoints for testing
694- asm = & oauthex.AuthServerMeta {
695- Issuer : s .URL (),
696- AuthorizationEndpoint : s .URL () + "/authorize" ,
697- TokenEndpoint : s .URL () + "/token" ,
698- RegistrationEndpoint : s .URL () + "/register" ,
699- }
700- }
701595 got , err := handler .handleRegistration (t .Context (), asm )
702596 if err != nil {
703597 t .Fatalf ("handleRegistration() error = %v, want nil" , err )
0 commit comments