Fix Broken Test

Issue gh-8589
This commit is contained in:
Josh Cummings 2020-07-31 13:45:10 -06:00
parent acfe4bdcfb
commit d956ebf59b
No known key found for this signature in database
GPG Key ID: 49EF60DD7FF83443

View File

@ -243,9 +243,14 @@ public class NimbusJwtDecoderJwkSupportTests {
} }
@Test @Test
public void decodeWhenReadingErrorPickTheFirstErrorMessage() { public void decodeWhenReadingErrorPickTheFirstErrorMessage() throws Exception {
try ( MockWebServer server = new MockWebServer() ) {
server.enqueue(new MockResponse().setBody(JWK_SET));
String jwkSetUrl = server.url("/.well-known/jwks.json").toString();
NimbusJwtDecoderJwkSupport decoder = new NimbusJwtDecoderJwkSupport(jwkSetUrl);
OAuth2TokenValidator<Jwt> jwtValidator = mock(OAuth2TokenValidator.class); OAuth2TokenValidator<Jwt> jwtValidator = mock(OAuth2TokenValidator.class);
this.jwtDecoder.setJwtValidator(jwtValidator); decoder.setJwtValidator(jwtValidator);
OAuth2Error errorEmpty = new OAuth2Error("mock-error", "", "mock-uri"); OAuth2Error errorEmpty = new OAuth2Error("mock-error", "", "mock-uri");
OAuth2Error error = new OAuth2Error("mock-error", "mock-description", "mock-uri"); OAuth2Error error = new OAuth2Error("mock-error", "mock-description", "mock-uri");
@ -253,10 +258,11 @@ public class NimbusJwtDecoderJwkSupportTests {
OAuth2TokenValidatorResult result = OAuth2TokenValidatorResult.failure(errorEmpty, error, error2); OAuth2TokenValidatorResult result = OAuth2TokenValidatorResult.failure(errorEmpty, error, error2);
Mockito.when(jwtValidator.validate(any(Jwt.class))).thenReturn(result); Mockito.when(jwtValidator.validate(any(Jwt.class))).thenReturn(result);
Assertions.assertThatCode(() -> this.jwtDecoder.decode(SIGNED_JWT)) Assertions.assertThatCode(() -> decoder.decode(SIGNED_JWT))
.isInstanceOf(JwtValidationException.class) .isInstanceOf(JwtValidationException.class)
.hasMessageContaining("mock-description"); .hasMessageContaining("mock-description");
} }
}
@Test @Test
public void decodeWhenUsingSignedJwtThenReturnsClaimsGivenByClaimSetConverter() throws Exception { public void decodeWhenUsingSignedJwtThenReturnsClaimsGivenByClaimSetConverter() throws Exception {