From b803e845e75da8e8927182dd5cb392bb592d51b6 Mon Sep 17 00:00:00 2001 From: Marcus Da Coregio Date: Tue, 10 May 2022 14:49:02 -0300 Subject: [PATCH] Use Spring Framework version 6.0.0-M3 Closes gh-11193 --- gradle.properties | 2 +- .../client/userinfo/DefaultReactiveOAuth2UserService.java | 4 ++-- .../client/http/OAuth2ErrorResponseErrorHandlerTests.java | 6 +++--- ...efaultServerOAuth2AuthorizationRequestResolverTests.java | 2 +- .../web/util/matcher/AntPathRequestMatcherTests.java | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 0d370ba04d..c3add94794 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ aspectjVersion=1.9.8 springJavaformatVersion=0.0.31 springBootVersion=2.4.2 -springFrameworkVersion=6.0.0-SNAPSHOT +springFrameworkVersion=6.0.0-M3 openSamlVersion=3.4.6 version=6.0.0-SNAPSHOT kotlinVersion=1.6.20-M1 diff --git a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserService.java b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserService.java index 9e3d19a665..abd48bd3c2 100644 --- a/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserService.java +++ b/oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserService.java @@ -27,7 +27,7 @@ import reactor.core.publisher.Mono; import org.springframework.core.ParameterizedTypeReference; import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatusCode; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; @@ -108,7 +108,7 @@ public class DefaultReactiveOAuth2UserService implements ReactiveOAuth2UserServi authenticationMethod); // @formatter:off Mono> userAttributes = requestHeadersSpec.retrieve() - .onStatus(HttpStatusCode::isError, (response) -> + .onStatus(HttpStatus::isError, (response) -> parse(response) .map((userInfoErrorResponse) -> { String description = userInfoErrorResponse.getErrorObject().getDescription(); diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/http/OAuth2ErrorResponseErrorHandlerTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/http/OAuth2ErrorResponseErrorHandlerTests.java index 0fd7d886b3..4e5c784029 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/http/OAuth2ErrorResponseErrorHandlerTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/http/OAuth2ErrorResponseErrorHandlerTests.java @@ -28,6 +28,7 @@ import org.springframework.mock.http.MockHttpInputMessage; import org.springframework.mock.http.client.MockClientHttpResponse; import org.springframework.security.oauth2.core.OAuth2AuthorizationException; import org.springframework.security.oauth2.core.OAuth2Error; +import org.springframework.web.client.UnknownHttpStatusCodeException; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; @@ -101,9 +102,8 @@ public class OAuth2ErrorResponseErrorHandlerTests { @Test public void handleErrorWhenErrorResponseWithInvalidStatusCodeThenHandled() { CustomMockClientHttpResponse response = new CustomMockClientHttpResponse(new byte[0], 596); - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> this.errorHandler.handleError(response)) - .withMessage("No matching constant for [596]"); + assertThatExceptionOfType(UnknownHttpStatusCodeException.class) + .isThrownBy(() -> this.errorHandler.handleError(response)).withMessage("596 : [no body]"); } private static final class CustomMockClientHttpResponse extends MockHttpInputMessage implements ClientHttpResponse { diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolverTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolverTests.java index f783c9076b..464d641c96 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolverTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/web/server/DefaultServerOAuth2AuthorizationRequestResolverTests.java @@ -81,7 +81,7 @@ public class DefaultServerOAuth2AuthorizationRequestResolverTests { given(this.clientRegistrationRepository.findByRegistrationId(any())).willReturn(Mono.empty()); assertThatExceptionOfType(ResponseStatusException.class) .isThrownBy(() -> resolve("/oauth2/authorization/not-found-id")) - .satisfies((ex) -> assertThat(ex.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST)); + .satisfies((ex) -> assertThat(ex.getStatus()).isEqualTo(HttpStatus.BAD_REQUEST)); } @Test diff --git a/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java b/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java index b90973257b..057e01ca04 100644 --- a/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java +++ b/web/src/test/java/org/springframework/security/web/util/matcher/AntPathRequestMatcherTests.java @@ -93,10 +93,10 @@ public class AntPathRequestMatcherTests { AntPathRequestMatcher matcher = new AntPathRequestMatcher("/**/{id}"); assertThat(matcher.matches(createRequest("/blah/1234"))).isTrue(); assertThat(matcher.matches(createRequest("/bleh/4567"))).isTrue(); - assertThat(matcher.matches(createRequest("/paskos/blah/"))).isFalse(); + assertThat(matcher.matches(createRequest("/paskos/blah/"))).isTrue(); assertThat(matcher.matches(createRequest("/12345/blah/xxx"))).isTrue(); assertThat(matcher.matches(createRequest("/12345/blaha"))).isTrue(); - assertThat(matcher.matches(createRequest("/paskos/bleh/"))).isFalse(); + assertThat(matcher.matches(createRequest("/paskos/bleh/"))).isTrue(); } @Test