Skip to content

Commit 283e451

Browse files
committed
Update JwtDecoders tests
Issue gh-7860
1 parent 431cd60 commit 283e451

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
import java.util.Map;
2121
import java.util.Optional;
2222

23+
import com.fasterxml.jackson.core.JsonProcessingException;
24+
import com.fasterxml.jackson.core.type.TypeReference;
25+
import com.fasterxml.jackson.databind.JsonMappingException;
26+
import com.fasterxml.jackson.databind.ObjectMapper;
2327
import okhttp3.HttpUrl;
2428
import okhttp3.mockwebserver.Dispatcher;
2529
import okhttp3.mockwebserver.MockResponse;
@@ -33,11 +37,6 @@
3337
import org.springframework.http.MediaType;
3438
import org.springframework.web.util.UriComponentsBuilder;
3539

36-
import com.fasterxml.jackson.core.JsonProcessingException;
37-
import com.fasterxml.jackson.core.type.TypeReference;
38-
import com.fasterxml.jackson.databind.JsonMappingException;
39-
import com.fasterxml.jackson.databind.ObjectMapper;
40-
4140
import static org.assertj.core.api.Assertions.assertThat;
4241
import static org.assertj.core.api.Assertions.assertThatCode;
4342

@@ -102,7 +101,7 @@ public void issuerWhenResponseIsTypicalThenReturnedDecoderValidatesIssuer() {
102101
JwtDecoder decoder = JwtDecoders.fromOidcIssuerLocation(this.issuer);
103102
assertThatCode(() -> decoder.decode(ISSUER_MISMATCH))
104103
.isInstanceOf(JwtValidationException.class)
105-
.hasMessageContaining("This iss claim is not equal to the configured issuer");
104+
.hasMessageContaining("The iss claim is not valid");
106105
}
107106

108107
@Test
@@ -111,7 +110,7 @@ public void issuerWhenOidcFallbackResponseIsTypicalThenReturnedDecoderValidatesI
111110
JwtDecoder decoder = JwtDecoders.fromIssuerLocation(this.issuer);
112111
assertThatCode(() -> decoder.decode(ISSUER_MISMATCH))
113112
.isInstanceOf(JwtValidationException.class)
114-
.hasMessageContaining("This iss claim is not equal to the configured issuer");
113+
.hasMessageContaining("The iss claim is not valid");
115114
}
116115

117116
@Test
@@ -120,7 +119,7 @@ public void issuerWhenOAuth2ResponseIsTypicalThenReturnedDecoderValidatesIssuer(
120119
JwtDecoder decoder = JwtDecoders.fromIssuerLocation(this.issuer);
121120
assertThatCode(() -> decoder.decode(ISSUER_MISMATCH))
122121
.isInstanceOf(JwtValidationException.class)
123-
.hasMessageContaining("This iss claim is not equal to the configured issuer");
122+
.hasMessageContaining("The iss claim is not valid");
124123
}
125124

126125
@Test

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

+7-8
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
import java.util.Map;
2121
import java.util.Optional;
2222

23+
import com.fasterxml.jackson.core.JsonProcessingException;
24+
import com.fasterxml.jackson.core.type.TypeReference;
25+
import com.fasterxml.jackson.databind.JsonMappingException;
26+
import com.fasterxml.jackson.databind.ObjectMapper;
2327
import okhttp3.HttpUrl;
2428
import okhttp3.mockwebserver.Dispatcher;
2529
import okhttp3.mockwebserver.MockResponse;
@@ -33,11 +37,6 @@
3337
import org.springframework.http.MediaType;
3438
import org.springframework.web.util.UriComponentsBuilder;
3539

36-
import com.fasterxml.jackson.core.JsonProcessingException;
37-
import com.fasterxml.jackson.core.type.TypeReference;
38-
import com.fasterxml.jackson.databind.JsonMappingException;
39-
import com.fasterxml.jackson.databind.ObjectMapper;
40-
4140
import static org.assertj.core.api.Assertions.assertThatCode;
4241

4342
/**
@@ -104,7 +103,7 @@ public void issuerWhenResponseIsTypicalThenReturnedDecoderValidatesIssuer() {
104103

105104
assertThatCode(() -> decoder.decode(ISSUER_MISMATCH).block())
106105
.isInstanceOf(JwtValidationException.class)
107-
.hasMessageContaining("This iss claim is not equal to the configured issuer");
106+
.hasMessageContaining("The iss claim is not valid");
108107
}
109108

110109
@Test
@@ -115,7 +114,7 @@ public void issuerWhenOidcFallbackResponseIsTypicalThenReturnedDecoderValidatesI
115114

116115
assertThatCode(() -> decoder.decode(ISSUER_MISMATCH).block())
117116
.isInstanceOf(JwtValidationException.class)
118-
.hasMessageContaining("This iss claim is not equal to the configured issuer");
117+
.hasMessageContaining("The iss claim is not valid");
119118
}
120119

121120
@Test
@@ -126,7 +125,7 @@ public void issuerWhenOAuth2ResponseIsTypicalThenReturnedDecoderValidatesIssuer(
126125

127126
assertThatCode(() -> decoder.decode(ISSUER_MISMATCH).block())
128127
.isInstanceOf(JwtValidationException.class)
129-
.hasMessageContaining("This iss claim is not equal to the configured issuer");
128+
.hasMessageContaining("The iss claim is not valid");
130129
}
131130

132131
@Test

0 commit comments

Comments
 (0)