瀏覽代碼

Test OpenID Discovery with Trailing Slash

Fixes gh-6234
Josh Cummings 6 年之前
父節點
當前提交
566bc6a6e1

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

@@ -137,6 +137,12 @@ public class ClientRegistrationsTest {
 		assertThat(provider.getUserInfoEndpoint().getUri()).isEqualTo("https://example.com/oauth2/v3/userinfo");
 	}
 
+	@Test
+	public void issuerWhenContainsTrailingSlashThenSuccess() throws Exception {
+		assertThat(registration("")).isNotNull();
+		assertThat(this.issuer.endsWith("/")).isTrue();
+	}
+
 	/**
 	 * https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
 	 *

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

@@ -24,6 +24,7 @@ import org.junit.Test;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatCode;
 
 /**
@@ -91,6 +92,14 @@ public class JwtDecodersTests {
 				.hasMessageContaining("This iss claim is not equal to the configured issuer");
 	}
 
+	@Test
+	public void issuerWhenContainsTrailingSlashThenSuccess() {
+		prepareOpenIdConfigurationResponse();
+		this.server.enqueue(new MockResponse().setBody(JWK_SET));
+		assertThat(JwtDecoders.fromOidcIssuerLocation(this.issuer)).isNotNull();
+		assertThat(this.issuer.endsWith("/")).isTrue();
+	}
+
 	@Test
 	public void issuerWhenResponseIsNonCompliantThenThrowsRuntimeException() {
 		prepareOpenIdConfigurationResponse("{ \"missing_required_keys\" : \"and_values\" }");