|
@@ -120,4 +120,33 @@ public class OAuth2BodyExtractorsTests {
|
|
|
assertThat(result.getRefreshToken().getTokenValue()).isEqualTo("tGzv3JOkF0XG5Qx2TlKWIA");
|
|
|
assertThat(result.getAdditionalParameters()).containsEntry("example_parameter", "example_value");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Test
|
|
|
+ // gh-6087
|
|
|
+ public void oauth2AccessTokenResponseWhenMultipleAttributeTypesThenCreated() throws Exception {
|
|
|
+ BodyExtractor<Mono<OAuth2AccessTokenResponse>, ReactiveHttpInputMessage> extractor = OAuth2BodyExtractors
|
|
|
+ .oauth2AccessTokenResponse();
|
|
|
+
|
|
|
+ MockClientHttpResponse response = new MockClientHttpResponse(HttpStatus.OK);
|
|
|
+ response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
|
|
|
+ response.setBody("{\n"
|
|
|
+ + " \"access_token\":\"2YotnFZFEjr1zCsicMWpAA\",\n"
|
|
|
+ + " \"token_type\":\"Bearer\",\n"
|
|
|
+ + " \"expires_in\":3600,\n"
|
|
|
+ + " \"refresh_token\":\"tGzv3JOkF0XG5Qx2TlKWIA\",\n"
|
|
|
+ + " \"subjson\":{}, \n"
|
|
|
+ + " \"list\":[] \n"
|
|
|
+ + " }");
|
|
|
+
|
|
|
+ Instant now = Instant.now();
|
|
|
+ OAuth2AccessTokenResponse result = extractor.extract(response, this.context).block();
|
|
|
+
|
|
|
+ assertThat(result.getAccessToken().getTokenValue()).isEqualTo("2YotnFZFEjr1zCsicMWpAA");
|
|
|
+ assertThat(result.getAccessToken().getTokenType()).isEqualTo(OAuth2AccessToken.TokenType.BEARER);
|
|
|
+ assertThat(result.getAccessToken().getExpiresAt()).isBetween(now.plusSeconds(3600), now.plusSeconds(3600 + 2));
|
|
|
+ assertThat(result.getRefreshToken().getTokenValue()).isEqualTo("tGzv3JOkF0XG5Qx2TlKWIA");
|
|
|
+ assertThat(result.getAdditionalParameters().get("subjson")).isInstanceOfAny(Map.class);
|
|
|
+ assertThat(result.getAdditionalParameters().get("list")).isInstanceOfAny(List.class);
|
|
|
+ }
|
|
|
}
|