@@ -712,16 +712,12 @@ describe('OAuth Authorization', () => {
712712 it ( 'generates correct URLs for server with path' , ( ) => {
713713 const urls = buildDiscoveryUrls ( 'https://auth.example.com/tenant1' ) ;
714714
715- expect ( urls ) . toHaveLength ( 4 ) ;
715+ expect ( urls ) . toHaveLength ( 3 ) ;
716716 expect ( urls . map ( u => ( { url : u . url . toString ( ) , type : u . type } ) ) ) . toEqual ( [
717717 {
718718 url : 'https://auth.example.com/.well-known/oauth-authorization-server/tenant1' ,
719719 type : 'oauth'
720720 } ,
721- {
722- url : 'https://auth.example.com/.well-known/oauth-authorization-server' ,
723- type : 'oauth'
724- } ,
725721 {
726722 url : 'https://auth.example.com/.well-known/openid-configuration/tenant1' ,
727723 type : 'oidc'
@@ -736,7 +732,7 @@ describe('OAuth Authorization', () => {
736732 it ( 'handles URL object input' , ( ) => {
737733 const urls = buildDiscoveryUrls ( new URL ( 'https://auth.example.com/tenant1' ) ) ;
738734
739- expect ( urls ) . toHaveLength ( 4 ) ;
735+ expect ( urls ) . toHaveLength ( 3 ) ;
740736 expect ( urls [ 0 ] . url . toString ( ) ) . toBe ( 'https://auth.example.com/.well-known/oauth-authorization-server/tenant1' ) ;
741737 } ) ;
742738 } ) ;
@@ -763,28 +759,28 @@ describe('OAuth Authorization', () => {
763759 } ;
764760
765761 it ( 'tries URLs in order and returns first successful metadata' , async ( ) => {
766- // First OAuth URL fails with 404
762+ // First OAuth URL (path before well-known) fails with 404
767763 mockFetch . mockResolvedValueOnce ( {
768764 ok : false ,
769765 status : 404
770766 } ) ;
771767
772- // Second OAuth URL (root ) succeeds
768+ // Second OIDC URL (path before well-known ) succeeds
773769 mockFetch . mockResolvedValueOnce ( {
774770 ok : true ,
775771 status : 200 ,
776- json : async ( ) => validOAuthMetadata
772+ json : async ( ) => validOpenIdMetadata
777773 } ) ;
778774
779775 const metadata = await discoverAuthorizationServerMetadata ( 'https://auth.example.com/tenant1' ) ;
780776
781- expect ( metadata ) . toEqual ( validOAuthMetadata ) ;
777+ expect ( metadata ) . toEqual ( validOpenIdMetadata ) ;
782778
783779 // Verify it tried the URLs in the correct order
784780 const calls = mockFetch . mock . calls ;
785781 expect ( calls . length ) . toBe ( 2 ) ;
786782 expect ( calls [ 0 ] [ 0 ] . toString ( ) ) . toBe ( 'https://auth.example.com/.well-known/oauth-authorization-server/tenant1' ) ;
787- expect ( calls [ 1 ] [ 0 ] . toString ( ) ) . toBe ( 'https://auth.example.com/.well-known/oauth-authorization-server ' ) ;
783+ expect ( calls [ 1 ] [ 0 ] . toString ( ) ) . toBe ( 'https://auth.example.com/.well-known/openid-configuration/tenant1 ' ) ;
788784 } ) ;
789785
790786 it ( 'continues on 4xx errors' , async ( ) => {
@@ -878,7 +874,7 @@ describe('OAuth Authorization', () => {
878874 expect ( metadata ) . toBeUndefined ( ) ;
879875
880876 // Verify that all discovery URLs were attempted
881- expect ( mockFetch ) . toHaveBeenCalledTimes ( 8 ) ; // 4 URLs × 2 attempts each (with and without headers)
877+ expect ( mockFetch ) . toHaveBeenCalledTimes ( 6 ) ; // 3 URLs × 2 attempts each (with and without headers)
882878 } ) ;
883879 } ) ;
884880
0 commit comments