mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-13 07:32:13 +00:00
Fix Broken Test
Issue gh-8589
This commit is contained in:
parent
acfe4bdcfb
commit
d956ebf59b
@ -243,19 +243,25 @@ public class NimbusJwtDecoderJwkSupportTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void decodeWhenReadingErrorPickTheFirstErrorMessage() {
|
public void decodeWhenReadingErrorPickTheFirstErrorMessage() throws Exception {
|
||||||
OAuth2TokenValidator<Jwt> jwtValidator = mock(OAuth2TokenValidator.class);
|
try ( MockWebServer server = new MockWebServer() ) {
|
||||||
this.jwtDecoder.setJwtValidator(jwtValidator);
|
server.enqueue(new MockResponse().setBody(JWK_SET));
|
||||||
|
String jwkSetUrl = server.url("/.well-known/jwks.json").toString();
|
||||||
|
|
||||||
OAuth2Error errorEmpty = new OAuth2Error("mock-error", "", "mock-uri");
|
NimbusJwtDecoderJwkSupport decoder = new NimbusJwtDecoderJwkSupport(jwkSetUrl);
|
||||||
OAuth2Error error = new OAuth2Error("mock-error", "mock-description", "mock-uri");
|
OAuth2TokenValidator<Jwt> jwtValidator = mock(OAuth2TokenValidator.class);
|
||||||
OAuth2Error error2 = new OAuth2Error("mock-error-second", "mock-description-second", "mock-uri-second");
|
decoder.setJwtValidator(jwtValidator);
|
||||||
OAuth2TokenValidatorResult result = OAuth2TokenValidatorResult.failure(errorEmpty, error, error2);
|
|
||||||
Mockito.when(jwtValidator.validate(any(Jwt.class))).thenReturn(result);
|
|
||||||
|
|
||||||
Assertions.assertThatCode(() -> this.jwtDecoder.decode(SIGNED_JWT))
|
OAuth2Error errorEmpty = new OAuth2Error("mock-error", "", "mock-uri");
|
||||||
.isInstanceOf(JwtValidationException.class)
|
OAuth2Error error = new OAuth2Error("mock-error", "mock-description", "mock-uri");
|
||||||
.hasMessageContaining("mock-description");
|
OAuth2Error error2 = new OAuth2Error("mock-error-second", "mock-description-second", "mock-uri-second");
|
||||||
|
OAuth2TokenValidatorResult result = OAuth2TokenValidatorResult.failure(errorEmpty, error, error2);
|
||||||
|
Mockito.when(jwtValidator.validate(any(Jwt.class))).thenReturn(result);
|
||||||
|
|
||||||
|
Assertions.assertThatCode(() -> decoder.decode(SIGNED_JWT))
|
||||||
|
.isInstanceOf(JwtValidationException.class)
|
||||||
|
.hasMessageContaining("mock-description");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user