Skip to content

Commit 566bc6a

Browse files
committed
Test OpenID Discovery with Trailing Slash
Fixes gh-6234
1 parent f755580 commit 566bc6a

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ public void issuerWhenAllInformationThenSuccess() throws Exception {
137137
assertThat(provider.getUserInfoEndpoint().getUri()).isEqualTo("https://example.com/oauth2/v3/userinfo");
138138
}
139139

140+
@Test
141+
public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception {
142+
assertThat(registration("")).isNotNull();
143+
assertThat(this.issuer.endsWith("/")).isTrue();
144+
}
145+
140146
/**
141147
* https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
142148
*

oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecodersTests.java

+9
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.http.HttpHeaders;
2525
import org.springframework.http.MediaType;
2626

27+
import static org.assertj.core.api.Assertions.assertThat;
2728
import static org.assertj.core.api.Assertions.assertThatCode;
2829

2930
/**
@@ -91,6 +92,14 @@ public void issuerWhenResponseIsTypicalThenReturnedDecoderValidatesIssuer() {
9192
.hasMessageContaining("This iss claim is not equal to the configured issuer");
9293
}
9394

95+
@Test
96+
public void issuerWhenContainsTrailingSlashThenSuccess() {
97+
prepareOpenIdConfigurationResponse();
98+
this.server.enqueue(new MockResponse().setBody(JWK_SET));
99+
assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull();
100+
assertThat(this.issuer.endsWith("/")).isTrue();
101+
}
102+
94103
@Test
95104
public void issuerWhenResponseIsNonCompliantThenThrowsRuntimeException() {
96105
prepareOpenIdConfigurationResponse("{ \"missing_required_keys\" : \"and_values\" }");

0 commit comments

Comments
 (0)