11/*
2- * Copyright 2020-2022 the original author or authors.
2+ * Copyright 2020-2023 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
@@ -38,43 +38,43 @@ public class OAuth2AuthorizationServerMetadataTests {
3838 // @formatter:off
3939 private final Builder minimalBuilder =
4040 OAuth2AuthorizationServerMetadata .builder ()
41- .issuer ("https://example.com/issuer1 " )
42- .authorizationEndpoint ("https://example.com/issuer1/ oauth2/authorize" )
43- .tokenEndpoint ("https://example.com/issuer1/ oauth2/token" )
41+ .issuer ("https://example.com" )
42+ .authorizationEndpoint ("https://example.com/oauth2/authorize" )
43+ .tokenEndpoint ("https://example.com/oauth2/token" )
4444 .responseType ("code" );
4545 // @formatter:on
4646
4747 @ Test
4848 public void buildWhenAllClaimsProvidedThenCreated () {
4949 OAuth2AuthorizationServerMetadata authorizationServerMetadata = OAuth2AuthorizationServerMetadata .builder ()
50- .issuer ("https://example.com/issuer1 " )
51- .authorizationEndpoint ("https://example.com/issuer1/ oauth2/authorize" )
52- .tokenEndpoint ("https://example.com/issuer1/ oauth2/token" )
50+ .issuer ("https://example.com" )
51+ .authorizationEndpoint ("https://example.com/oauth2/authorize" )
52+ .tokenEndpoint ("https://example.com/oauth2/token" )
5353 .tokenEndpointAuthenticationMethod (ClientAuthenticationMethod .CLIENT_SECRET_BASIC .getValue ())
54- .jwkSetUrl ("https://example.com/issuer1/ oauth2/jwks" )
54+ .jwkSetUrl ("https://example.com/oauth2/jwks" )
5555 .scope ("openid" )
5656 .responseType ("code" )
5757 .grantType ("authorization_code" )
5858 .grantType ("client_credentials" )
59- .tokenRevocationEndpoint ("https://example.com/issuer1/ oauth2/revoke" )
59+ .tokenRevocationEndpoint ("https://example.com/oauth2/revoke" )
6060 .tokenRevocationEndpointAuthenticationMethod (ClientAuthenticationMethod .CLIENT_SECRET_BASIC .getValue ())
61- .tokenIntrospectionEndpoint ("https://example.com/issuer1/ oauth2/introspect" )
61+ .tokenIntrospectionEndpoint ("https://example.com/oauth2/introspect" )
6262 .tokenIntrospectionEndpointAuthenticationMethod (ClientAuthenticationMethod .CLIENT_SECRET_BASIC .getValue ())
6363 .codeChallengeMethod ("S256" )
6464 .claim ("a-claim" , "a-value" )
6565 .build ();
6666
67- assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com/issuer1 " ));
68- assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/authorize" ));
69- assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/token" ));
67+ assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com" ));
68+ assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/authorize" ));
69+ assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/oauth2/token" ));
7070 assertThat (authorizationServerMetadata .getTokenEndpointAuthenticationMethods ()).containsExactly (ClientAuthenticationMethod .CLIENT_SECRET_BASIC .getValue ());
71- assertThat (authorizationServerMetadata .getJwkSetUrl ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/jwks" ));
71+ assertThat (authorizationServerMetadata .getJwkSetUrl ()).isEqualTo (url ("https://example.com/oauth2/jwks" ));
7272 assertThat (authorizationServerMetadata .getScopes ()).containsExactly ("openid" );
7373 assertThat (authorizationServerMetadata .getResponseTypes ()).containsExactly ("code" );
7474 assertThat (authorizationServerMetadata .getGrantTypes ()).containsExactlyInAnyOrder ("authorization_code" , "client_credentials" );
75- assertThat (authorizationServerMetadata .getTokenRevocationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/revoke" ));
75+ assertThat (authorizationServerMetadata .getTokenRevocationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/revoke" ));
7676 assertThat (authorizationServerMetadata .getTokenRevocationEndpointAuthenticationMethods ()).containsExactly (ClientAuthenticationMethod .CLIENT_SECRET_BASIC .getValue ());
77- assertThat (authorizationServerMetadata .getTokenIntrospectionEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/introspect" ));
77+ assertThat (authorizationServerMetadata .getTokenIntrospectionEndpoint ()).isEqualTo (url ("https://example.com/oauth2/introspect" ));
7878 assertThat (authorizationServerMetadata .getTokenIntrospectionEndpointAuthenticationMethods ()).containsExactly (ClientAuthenticationMethod .CLIENT_SECRET_BASIC .getValue ());
7979 assertThat (authorizationServerMetadata .getCodeChallengeMethods ()).containsExactly ("S256" );
8080 assertThat (authorizationServerMetadata .getClaimAsString ("a-claim" )).isEqualTo ("a-value" );
@@ -83,15 +83,15 @@ public void buildWhenAllClaimsProvidedThenCreated() {
8383 @ Test
8484 public void buildWhenOnlyRequiredClaimsProvidedThenCreated () {
8585 OAuth2AuthorizationServerMetadata authorizationServerMetadata = OAuth2AuthorizationServerMetadata .builder ()
86- .issuer ("https://example.com/issuer1 " )
87- .authorizationEndpoint ("https://example.com/issuer1/ oauth2/authorize" )
88- .tokenEndpoint ("https://example.com/issuer1/ oauth2/token" )
86+ .issuer ("https://example.com" )
87+ .authorizationEndpoint ("https://example.com/oauth2/authorize" )
88+ .tokenEndpoint ("https://example.com/oauth2/token" )
8989 .responseType ("code" )
9090 .build ();
9191
92- assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com/issuer1 " ));
93- assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/authorize" ));
94- assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/token" ));
92+ assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com" ));
93+ assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/authorize" ));
94+ assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/oauth2/token" ));
9595 assertThat (authorizationServerMetadata .getTokenEndpointAuthenticationMethods ()).isNull ();
9696 assertThat (authorizationServerMetadata .getJwkSetUrl ()).isNull ();
9797 assertThat (authorizationServerMetadata .getScopes ()).isNull ();
@@ -107,29 +107,29 @@ public void buildWhenOnlyRequiredClaimsProvidedThenCreated() {
107107 @ Test
108108 public void withClaimsWhenClaimsProvidedThenCreated () {
109109 HashMap <String , Object > claims = new HashMap <>();
110- claims .put (OAuth2AuthorizationServerMetadataClaimNames .ISSUER , "https://example.com/issuer1 " );
111- claims .put (OAuth2AuthorizationServerMetadataClaimNames .AUTHORIZATION_ENDPOINT , "https://example.com/issuer1/ oauth2/authorize" );
112- claims .put (OAuth2AuthorizationServerMetadataClaimNames .TOKEN_ENDPOINT , "https://example.com/issuer1/ oauth2/token" );
113- claims .put (OAuth2AuthorizationServerMetadataClaimNames .JWKS_URI , "https://example.com/issuer1/ oauth2/jwks" );
110+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .ISSUER , "https://example.com" );
111+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .AUTHORIZATION_ENDPOINT , "https://example.com/oauth2/authorize" );
112+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .TOKEN_ENDPOINT , "https://example.com/oauth2/token" );
113+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .JWKS_URI , "https://example.com/oauth2/jwks" );
114114 claims .put (OAuth2AuthorizationServerMetadataClaimNames .SCOPES_SUPPORTED , Collections .singletonList ("openid" ));
115115 claims .put (OAuth2AuthorizationServerMetadataClaimNames .RESPONSE_TYPES_SUPPORTED , Collections .singletonList ("code" ));
116- claims .put (OAuth2AuthorizationServerMetadataClaimNames .REVOCATION_ENDPOINT , "https://example.com/issuer1/ oauth2/revoke" );
117- claims .put (OAuth2AuthorizationServerMetadataClaimNames .INTROSPECTION_ENDPOINT , "https://example.com/issuer1/ oauth2/introspect" );
116+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .REVOCATION_ENDPOINT , "https://example.com/oauth2/revoke" );
117+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .INTROSPECTION_ENDPOINT , "https://example.com/oauth2/introspect" );
118118 claims .put ("some-claim" , "some-value" );
119119
120120 OAuth2AuthorizationServerMetadata authorizationServerMetadata = OAuth2AuthorizationServerMetadata .withClaims (claims ).build ();
121121
122- assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com/issuer1 " ));
123- assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/authorize" ));
124- assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/token" ));
122+ assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com" ));
123+ assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/authorize" ));
124+ assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/oauth2/token" ));
125125 assertThat (authorizationServerMetadata .getTokenEndpointAuthenticationMethods ()).isNull ();
126- assertThat (authorizationServerMetadata .getJwkSetUrl ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/jwks" ));
126+ assertThat (authorizationServerMetadata .getJwkSetUrl ()).isEqualTo (url ("https://example.com/oauth2/jwks" ));
127127 assertThat (authorizationServerMetadata .getScopes ()).containsExactly ("openid" );
128128 assertThat (authorizationServerMetadata .getResponseTypes ()).containsExactly ("code" );
129129 assertThat (authorizationServerMetadata .getGrantTypes ()).isNull ();
130- assertThat (authorizationServerMetadata .getTokenRevocationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/revoke" ));
130+ assertThat (authorizationServerMetadata .getTokenRevocationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/revoke" ));
131131 assertThat (authorizationServerMetadata .getTokenRevocationEndpointAuthenticationMethods ()).isNull ();
132- assertThat (authorizationServerMetadata .getTokenIntrospectionEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/introspect" ));
132+ assertThat (authorizationServerMetadata .getTokenIntrospectionEndpoint ()).isEqualTo (url ("https://example.com/oauth2/introspect" ));
133133 assertThat (authorizationServerMetadata .getTokenIntrospectionEndpointAuthenticationMethods ()).isNull ();
134134 assertThat (authorizationServerMetadata .getCodeChallengeMethods ()).isNull ();
135135 assertThat (authorizationServerMetadata .getClaimAsString ("some-claim" )).isEqualTo ("some-value" );
@@ -138,28 +138,28 @@ public void withClaimsWhenClaimsProvidedThenCreated() {
138138 @ Test
139139 public void withClaimsWhenClaimsWithUrlsProvidedThenCreated () {
140140 HashMap <String , Object > claims = new HashMap <>();
141- claims .put (OAuth2AuthorizationServerMetadataClaimNames .ISSUER , url ("https://example.com/issuer1 " ));
142- claims .put (OAuth2AuthorizationServerMetadataClaimNames .AUTHORIZATION_ENDPOINT , url ("https://example.com/issuer1/ oauth2/authorize" ));
143- claims .put (OAuth2AuthorizationServerMetadataClaimNames .TOKEN_ENDPOINT , url ("https://example.com/issuer1/ oauth2/token" ));
144- claims .put (OAuth2AuthorizationServerMetadataClaimNames .JWKS_URI , url ("https://example.com/issuer1/ oauth2/jwks" ));
141+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .ISSUER , url ("https://example.com" ));
142+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .AUTHORIZATION_ENDPOINT , url ("https://example.com/oauth2/authorize" ));
143+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .TOKEN_ENDPOINT , url ("https://example.com/oauth2/token" ));
144+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .JWKS_URI , url ("https://example.com/oauth2/jwks" ));
145145 claims .put (OAuth2AuthorizationServerMetadataClaimNames .RESPONSE_TYPES_SUPPORTED , Collections .singletonList ("code" ));
146- claims .put (OAuth2AuthorizationServerMetadataClaimNames .REVOCATION_ENDPOINT , url ("https://example.com/issuer1/ oauth2/revoke" ));
147- claims .put (OAuth2AuthorizationServerMetadataClaimNames .INTROSPECTION_ENDPOINT , url ("https://example.com/issuer1/ oauth2/introspect" ));
146+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .REVOCATION_ENDPOINT , url ("https://example.com/oauth2/revoke" ));
147+ claims .put (OAuth2AuthorizationServerMetadataClaimNames .INTROSPECTION_ENDPOINT , url ("https://example.com/oauth2/introspect" ));
148148 claims .put ("some-claim" , "some-value" );
149149
150150 OAuth2AuthorizationServerMetadata authorizationServerMetadata = OAuth2AuthorizationServerMetadata .withClaims (claims ).build ();
151151
152- assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com/issuer1 " ));
153- assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/authorize" ));
154- assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/token" ));
152+ assertThat (authorizationServerMetadata .getIssuer ()).isEqualTo (url ("https://example.com" ));
153+ assertThat (authorizationServerMetadata .getAuthorizationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/authorize" ));
154+ assertThat (authorizationServerMetadata .getTokenEndpoint ()).isEqualTo (url ("https://example.com/oauth2/token" ));
155155 assertThat (authorizationServerMetadata .getTokenEndpointAuthenticationMethods ()).isNull ();
156- assertThat (authorizationServerMetadata .getJwkSetUrl ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/jwks" ));
156+ assertThat (authorizationServerMetadata .getJwkSetUrl ()).isEqualTo (url ("https://example.com/oauth2/jwks" ));
157157 assertThat (authorizationServerMetadata .getScopes ()).isNull ();
158158 assertThat (authorizationServerMetadata .getResponseTypes ()).containsExactly ("code" );
159159 assertThat (authorizationServerMetadata .getGrantTypes ()).isNull ();
160- assertThat (authorizationServerMetadata .getTokenRevocationEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/revoke" ));
160+ assertThat (authorizationServerMetadata .getTokenRevocationEndpoint ()).isEqualTo (url ("https://example.com/oauth2/revoke" ));
161161 assertThat (authorizationServerMetadata .getTokenRevocationEndpointAuthenticationMethods ()).isNull ();
162- assertThat (authorizationServerMetadata .getTokenIntrospectionEndpoint ()).isEqualTo (url ("https://example.com/issuer1/ oauth2/introspect" ));
162+ assertThat (authorizationServerMetadata .getTokenIntrospectionEndpoint ()).isEqualTo (url ("https://example.com/oauth2/introspect" ));
163163 assertThat (authorizationServerMetadata .getTokenIntrospectionEndpointAuthenticationMethods ()).isNull ();
164164 assertThat (authorizationServerMetadata .getCodeChallengeMethods ()).isNull ();
165165 assertThat (authorizationServerMetadata .getClaimAsString ("some-claim" )).isEqualTo ("some-value" );
0 commit comments