diff --git a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2AuthorizationCodeReactiveAuthenticationManagerTests.java b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2AuthorizationCodeReactiveAuthenticationManagerTests.java index f5112dbcb8..bd62f84d07 100644 --- a/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2AuthorizationCodeReactiveAuthenticationManagerTests.java +++ b/oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/authentication/OAuth2AuthorizationCodeReactiveAuthenticationManagerTests.java @@ -21,6 +21,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import reactor.core.publisher.Mono; + import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest; import org.springframework.security.oauth2.client.endpoint.ReactiveOAuth2AccessTokenResponseClient; import org.springframework.security.oauth2.client.registration.ClientRegistration; @@ -34,12 +36,11 @@ import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationResp import org.springframework.security.oauth2.core.endpoint.TestOAuth2AccessTokenResponses; import org.springframework.security.oauth2.core.endpoint.TestOAuth2AuthorizationRequests; import org.springframework.security.oauth2.core.endpoint.TestOAuth2AuthorizationResponses; -import reactor.core.publisher.Mono; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.mockito.ArgumentMatchers.any; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.mockito.Mockito.when; /** * @author Rob Winch diff --git a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationExchangeTests.java b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationExchangeTests.java index 99c59f50c6..35f02806a9 100644 --- a/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationExchangeTests.java +++ b/oauth2/oauth2-core/src/test/java/org/springframework/security/oauth2/core/endpoint/OAuth2AuthorizationExchangeTests.java @@ -16,36 +16,32 @@ package org.springframework.security.oauth2.core.endpoint; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; +import static org.springframework.security.oauth2.core.endpoint.TestOAuth2AuthorizationRequests.request; +import static org.springframework.security.oauth2.core.endpoint.TestOAuth2AuthorizationResponses.success; /** * Tests for {@link OAuth2AuthorizationExchange}. * * @author Joe Grandja */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({OAuth2AuthorizationExchange.class, OAuth2AuthorizationRequest.class, OAuth2AuthorizationResponse.class}) public class OAuth2AuthorizationExchangeTests { @Test(expected = IllegalArgumentException.class) public void constructorWhenAuthorizationRequestIsNullThenThrowIllegalArgumentException() { - new OAuth2AuthorizationExchange(null, mock(OAuth2AuthorizationResponse.class)); + new OAuth2AuthorizationExchange(null, success().build()); } @Test(expected = IllegalArgumentException.class) public void constructorWhenAuthorizationResponseIsNullThenThrowIllegalArgumentException() { - new OAuth2AuthorizationExchange(mock(OAuth2AuthorizationRequest.class), null); + new OAuth2AuthorizationExchange(request().build(), null); } @Test public void constructorWhenRequiredArgsProvidedThenCreated() { - OAuth2AuthorizationRequest authorizationRequest = mock(OAuth2AuthorizationRequest.class); - OAuth2AuthorizationResponse authorizationResponse = mock(OAuth2AuthorizationResponse.class); + OAuth2AuthorizationRequest authorizationRequest = request().build(); + OAuth2AuthorizationResponse authorizationResponse = success().build(); OAuth2AuthorizationExchange authorizationExchange = new OAuth2AuthorizationExchange(authorizationRequest, authorizationResponse); assertThat(authorizationExchange.getAuthorizationRequest()).isEqualTo(authorizationRequest); 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 c0cd424ab0..580a3d4c0b 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 @@ -20,16 +20,10 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; -import com.nimbusds.jwt.JWTParser; import okhttp3.mockwebserver.MockResponse; import okhttp3.mockwebserver.MockWebServer; import org.assertj.core.api.Assertions; import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.core.convert.converter.Converter; import org.springframework.http.HttpStatus; @@ -48,9 +42,9 @@ import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; -import static org.powermock.api.mockito.PowerMockito.spy; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.mockito.Mockito.when; /** * Tests for {@link NimbusJwtDecoderJwkSupport}. @@ -58,9 +52,6 @@ import static org.powermock.api.mockito.PowerMockito.when; * @author Joe Grandja * @author Josh Cummings */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({NimbusJwtDecoderJwkSupport.class, JWTParser.class}) -@PowerMockIgnore("okhttp3.*") public class NimbusJwtDecoderJwkSupportTests { private static final String JWK_SET_URL = "https://provider.com/oauth2/keys"; private static final String JWS_ALGORITHM = JwsAlgorithms.RS256; @@ -248,7 +239,7 @@ public class NimbusJwtDecoderJwkSupportTests { private static RestOperations mockJwkSetResponse(String response) { RestOperations restOperations = mock(RestOperations.class); - Mockito.when(restOperations.exchange(any(RequestEntity.class), eq(String.class))) + when(restOperations.exchange(any(RequestEntity.class), eq(String.class))) .thenReturn(new ResponseEntity<>(response, HttpStatus.OK)); return restOperations; }