From becff23df15f37835291dd9fba299192902dba76 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Mon, 16 Jul 2018 14:43:57 -0600 Subject: [PATCH] Reliable Error State Tests - Nimbus A test against the Nimbus library was relying on specific messaging from Nimbus as well as the JDK, making it brittle. Now, it simply relies on the messaging that we control. Issue: gh-4887 --- .../security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java index e90560cca7..675445f634 100644 --- a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java +++ b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/NimbusJwtDecoderJwkSupportTests.java @@ -146,7 +146,7 @@ public class NimbusJwtDecoderJwkSupportTests { } @Test - public void decodeWhenJwkEndpointIsUnresponsiveThenReturnsStockException() throws Exception { + public void decodeWhenJwkEndpointIsUnresponsiveThenRetrunsJwtException() throws Exception { try ( MockWebServer server = new MockWebServer() ) { server.enqueue(new MockResponse().setBody(MALFORMED_JWK_SET)); String jwkSetUrl = server.url("/.well-known/jwks.json").toString(); @@ -157,8 +157,7 @@ public class NimbusJwtDecoderJwkSupportTests { assertThatCode(() -> decoder.decode(SIGNED_JWT)) .isInstanceOf(JwtException.class) - .hasMessage("An error occurred while attempting to decode the Jwt: " + - "Couldn't retrieve remote JWK set: Connection refused (Connection refused)"); + .hasMessageContaining("An error occurred while attempting to decode the Jwt"); } } }