From f3f11066241d36e0b291e61eabf68c49cfe765c2 Mon Sep 17 00:00:00 2001 From: Rob Winch Date: Mon, 5 Apr 2021 22:03:45 -0500 Subject: [PATCH] Update io.spring.javaformat to 0.0.27 Closes gh-9553 --- gradle.properties | 2 +- .../jwt/JwtDecoderProviderConfigurationUtilsTests.java | 8 ++++---- ...tIssuerReactiveAuthenticationManagerResolverTests.java | 6 +++--- .../AuthenticationPrincipalArgumentResolverTests.java | 4 ++-- .../CurrentSecurityContextArgumentResolverTests.java | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/gradle.properties b/gradle.properties index 328eee4ce3..10bd5d1125 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ aspectjVersion=1.9.6 -springJavaformatVersion=0.0.25 +springJavaformatVersion=0.0.27 springBootVersion=2.4.2 openSamlVersion=3.4.6 version=5.5.0-SNAPSHOT diff --git a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecoderProviderConfigurationUtilsTests.java b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecoderProviderConfigurationUtilsTests.java index 31de6e4c23..31b3c0ace9 100644 --- a/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecoderProviderConfigurationUtilsTests.java +++ b/oauth2/oauth2-jose/src/test/java/org/springframework/security/oauth2/jwt/JwtDecoderProviderConfigurationUtilsTests.java @@ -38,8 +38,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.mock; -import static org.mockito.BDDMockito.when; public class JwtDecoderProviderConfigurationUtilsTests { @@ -48,7 +48,7 @@ public class JwtDecoderProviderConfigurationUtilsTests { JWKSource jwkSource = mock(JWKSource.class); RSAKey key = new RSAKey.Builder(TestKeys.DEFAULT_PUBLIC_KEY).keyUse(KeyUse.SIGNATURE) .algorithm(JWSAlgorithm.RS384).build(); - when(jwkSource.get(any(JWKSelector.class), isNull())).thenReturn(Collections.singletonList(key)); + given(jwkSource.get(any(JWKSelector.class), isNull())).willReturn(Collections.singletonList(key)); Set algorithms = JwtDecoderProviderConfigurationUtils.getSignatureAlgorithms(jwkSource); assertThat(algorithms).containsOnly(SignatureAlgorithm.RS384); } @@ -56,7 +56,7 @@ public class JwtDecoderProviderConfigurationUtilsTests { @Test public void getSignatureAlgorithmsWhenJwkSetIsEmptyThenIllegalArgumentException() throws Exception { JWKSource jwkSource = mock(JWKSource.class); - when(jwkSource.get(any(JWKSelector.class), isNull())).thenReturn(Collections.emptyList()); + given(jwkSource.get(any(JWKSelector.class), isNull())).willReturn(Collections.emptyList()); assertThatIllegalArgumentException() .isThrownBy(() -> JwtDecoderProviderConfigurationUtils.getSignatureAlgorithms(jwkSource)); } @@ -68,7 +68,7 @@ public class JwtDecoderProviderConfigurationUtilsTests { ECKey ecKey = new ECKey.Builder(Curve.P_256, new Base64URL("3l2Da_flYc-AuUTm2QzxgyvJxYM_2TeB9DMlwz7j1PE"), new Base64URL("-kjT7Wrfhwsi9SG6H4UXiyUiVE9GHCLauslksZ3-_t0")).keyUse(KeyUse.SIGNATURE).build(); RSAKey rsaKey = new RSAKey.Builder(TestKeys.DEFAULT_PUBLIC_KEY).keyUse(KeyUse.ENCRYPTION).build(); - when(jwkSource.get(any(JWKSelector.class), isNull())).thenReturn(Arrays.asList(ecKey, rsaKey)); + given(jwkSource.get(any(JWKSelector.class), isNull())).willReturn(Arrays.asList(ecKey, rsaKey)); Set algorithms = JwtDecoderProviderConfigurationUtils.getSignatureAlgorithms(jwkSource); assertThat(algorithms).contains(SignatureAlgorithm.ES256, SignatureAlgorithm.ES384, SignatureAlgorithm.ES512); } diff --git a/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolverTests.java b/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolverTests.java index f691c36aa6..81ee467720 100644 --- a/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolverTests.java +++ b/oauth2/oauth2-resource-server/src/test/java/org/springframework/security/oauth2/server/resource/authentication/JwtIssuerReactiveAuthenticationManagerResolverTests.java @@ -47,9 +47,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; import static org.mockito.BDDMockito.any; +import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.mock; import static org.mockito.BDDMockito.verify; -import static org.mockito.BDDMockito.when; /** * Tests for {@link JwtIssuerReactiveAuthenticationManagerResolver} @@ -129,7 +129,7 @@ public class JwtIssuerReactiveAuthenticationManagerResolverTests { public void resolveWhenUsingCustomIssuerAuthenticationManagerResolverThenUses() { Authentication token = withBearerToken(this.jwt); ReactiveAuthenticationManager authenticationManager = mock(ReactiveAuthenticationManager.class); - when(authenticationManager.authenticate(token)).thenReturn(Mono.empty()); + given(authenticationManager.authenticate(token)).willReturn(Mono.empty()); JwtIssuerReactiveAuthenticationManagerResolver authenticationManagerResolver = new JwtIssuerReactiveAuthenticationManagerResolver( (issuer) -> Mono.just(authenticationManager)); authenticationManagerResolver.resolve(null).flatMap((manager) -> manager.authenticate(token)).block(); @@ -147,7 +147,7 @@ public class JwtIssuerReactiveAuthenticationManagerResolverTests { .flatMap((manager) -> manager.authenticate(token)).block()) .withMessageContaining("Invalid issuer"); ReactiveAuthenticationManager authenticationManager = mock(ReactiveAuthenticationManager.class); - when(authenticationManager.authenticate(token)).thenReturn(Mono.empty()); + given(authenticationManager.authenticate(token)).willReturn(Mono.empty()); authenticationManagers.put("trusted", authenticationManager); authenticationManagerResolver.resolve(null).flatMap((manager) -> manager.authenticate(token)).block(); verify(authenticationManager).authenticate(token); diff --git a/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java index dc42226bda..a9bb9d009b 100644 --- a/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/method/annotation/AuthenticationPrincipalArgumentResolverTests.java @@ -40,9 +40,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.mock; import static org.mockito.BDDMockito.verify; -import static org.mockito.BDDMockito.when; /** * @author Rob Winch @@ -141,7 +141,7 @@ public class AuthenticationPrincipalArgumentResolverTests { public void resolveArgumentSpelBean() throws Exception { CustomUserPrincipal principal = new CustomUserPrincipal(); setAuthenticationPrincipal(principal); - when(this.beanResolver.resolve(any(), eq("test"))).thenReturn(principal.property); + given(this.beanResolver.resolve(any(), eq("test"))).willReturn(principal.property); this.expectedPrincipal = principal.property; assertThat(this.resolver.resolveArgument(showUserSpelBean(), null, null, null)) .isEqualTo(this.expectedPrincipal); diff --git a/web/src/test/java/org/springframework/security/web/method/annotation/CurrentSecurityContextArgumentResolverTests.java b/web/src/test/java/org/springframework/security/web/method/annotation/CurrentSecurityContextArgumentResolverTests.java index f33bc38f5a..2a2a17178a 100644 --- a/web/src/test/java/org/springframework/security/web/method/annotation/CurrentSecurityContextArgumentResolverTests.java +++ b/web/src/test/java/org/springframework/security/web/method/annotation/CurrentSecurityContextArgumentResolverTests.java @@ -42,9 +42,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.mock; import static org.mockito.BDDMockito.verify; -import static org.mockito.BDDMockito.when; /** * @author Dan Zheng @@ -119,7 +119,7 @@ public class CurrentSecurityContextArgumentResolverTests { @Test public void resolveArgumentWithAuthenticationWithBean() throws Exception { String principal = "john"; - when(this.beanResolver.resolve(any(), eq("test"))).thenReturn(principal); + given(this.beanResolver.resolve(any(), eq("test"))).willReturn(principal); assertThat(this.resolver.resolveArgument(showSecurityContextAuthenticationWithBean(), null, null, null)) .isEqualTo(principal); verify(this.beanResolver).resolve(any(), eq("test"));