Browse Source

Format authorizeRequests Blocks

This commit changes all auhorizeRequests
declarations to use the same variable name
and declare the lambda parameter and reference
on the same line.

Issue gh-13067
pull/17219/head
Josh Cummings 6 months ago
parent
commit
cf6b52d6f7
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
  1. 6
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurerTests.java
  2. 12
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/AuthorizeRequestsTests.java
  3. 9
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurerTests.java
  4. 3
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerAccessDeniedHandlerTests.java
  5. 9
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java
  6. 3
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurerTests.java
  7. 6
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/HttpSecurityRequestMatchersTests.java
  8. 9
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurerTests.java
  9. 9
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpBasicTests.java
  10. 6
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpServerAccessDeniedHandlerTests.java
  11. 9
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java
  12. 9
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurerTests.java
  13. 3
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/RequestMatcherConfigurerTests.java
  14. 3
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurerTests.java
  15. 22
      config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java

6
config/src/test/java/org/springframework/security/config/annotation/web/configurers/AnonymousConfigurerTests.java

@ -147,8 +147,7 @@ public class AnonymousConfigurerTests { @@ -147,8 +147,7 @@ public class AnonymousConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().permitAll()
)
.anonymous(AbstractHttpConfigurer::disable);
@ -171,8 +170,7 @@ public class AnonymousConfigurerTests { @@ -171,8 +170,7 @@ public class AnonymousConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().permitAll()
)
.anonymous(withDefaults());

12
config/src/test/java/org/springframework/security/config/annotation/web/configurers/AuthorizeRequestsTests.java

@ -219,8 +219,7 @@ public class AuthorizeRequestsTests { @@ -219,8 +219,7 @@ public class AuthorizeRequestsTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers(new AntPathRequestMatcher("/**", HttpMethod.POST.name())).denyAll()
);
// @formatter:on
@ -349,8 +348,7 @@ public class AuthorizeRequestsTests { @@ -349,8 +348,7 @@ public class AuthorizeRequestsTests {
// @formatter:off
http
.httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers("/path").denyAll()
);
// @formatter:on
@ -421,8 +419,7 @@ public class AuthorizeRequestsTests { @@ -421,8 +419,7 @@ public class AuthorizeRequestsTests {
// @formatter:off
http
.httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers(mvcMatcherBuilder.pattern("/path")).denyAll()
);
// @formatter:on
@ -489,8 +486,7 @@ public class AuthorizeRequestsTests { @@ -489,8 +486,7 @@ public class AuthorizeRequestsTests {
// @formatter:off
http
.httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers("/user/{userName}").access("#userName == 'user'")
);
// @formatter:on

9
config/src/test/java/org/springframework/security/config/annotation/web/configurers/CorsConfigurerTests.java

@ -251,8 +251,7 @@ public class CorsConfigurerTests { @@ -251,8 +251,7 @@ public class CorsConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.cors(withDefaults());
@ -308,8 +307,7 @@ public class CorsConfigurerTests { @@ -308,8 +307,7 @@ public class CorsConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.cors(withDefaults());
@ -364,8 +362,7 @@ public class CorsConfigurerTests { @@ -364,8 +362,7 @@ public class CorsConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.cors(withDefaults());

3
config/src/test/java/org/springframework/security/config/annotation/web/configurers/ExceptionHandlingConfigurerAccessDeniedHandlerTests.java

@ -113,8 +113,7 @@ public class ExceptionHandlingConfigurerAccessDeniedHandlerTests { @@ -113,8 +113,7 @@ public class ExceptionHandlingConfigurerAccessDeniedHandlerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().denyAll()
)
.exceptionHandling((exceptionHandling) ->

9
config/src/test/java/org/springframework/security/config/annotation/web/configurers/FormLoginConfigurerTests.java

@ -453,8 +453,7 @@ public class FormLoginConfigurerTests { @@ -453,8 +453,7 @@ public class FormLoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.formLogin(withDefaults());
@ -516,8 +515,7 @@ public class FormLoginConfigurerTests { @@ -516,8 +515,7 @@ public class FormLoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.formLogin((formLogin) ->
@ -572,8 +570,7 @@ public class FormLoginConfigurerTests { @@ -572,8 +570,7 @@ public class FormLoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.formLogin((formLogin) ->

3
config/src/test/java/org/springframework/security/config/annotation/web/configurers/HttpBasicConfigurerTests.java

@ -250,8 +250,7 @@ public class HttpBasicConfigurerTests { @@ -250,8 +250,7 @@ public class HttpBasicConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.httpBasic(withDefaults());

6
config/src/test/java/org/springframework/security/config/annotation/web/configurers/HttpSecurityRequestMatchersTests.java

@ -341,8 +341,7 @@ public class HttpSecurityRequestMatchersTests { @@ -341,8 +341,7 @@ public class HttpSecurityRequestMatchersTests {
.requestMatchers(new MvcRequestMatcher(introspector, "/path"))
)
.httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().denyAll()
);
return http.build();
@ -416,8 +415,7 @@ public class HttpSecurityRequestMatchersTests { @@ -416,8 +415,7 @@ public class HttpSecurityRequestMatchersTests {
.requestMatchers("/never-match")
)
.httpBasic(withDefaults())
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().denyAll()
);
return http.build();

9
config/src/test/java/org/springframework/security/config/annotation/web/configurers/JeeConfigurerTests.java

@ -209,8 +209,7 @@ public class JeeConfigurerTests { @@ -209,8 +209,7 @@ public class JeeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.jee((jee) ->
@ -231,8 +230,7 @@ public class JeeConfigurerTests { @@ -231,8 +230,7 @@ public class JeeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.jee((jee) ->
@ -256,8 +254,7 @@ public class JeeConfigurerTests { @@ -256,8 +254,7 @@ public class JeeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.jee((jee) ->

9
config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpBasicTests.java

@ -200,8 +200,7 @@ public class NamespaceHttpBasicTests { @@ -200,8 +200,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.httpBasic(withDefaults());
@ -236,8 +235,7 @@ public class NamespaceHttpBasicTests { @@ -236,8 +235,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.httpBasic((httpBasicConfig) -> httpBasicConfig.realmName("Custom Realm"));
@ -325,8 +323,7 @@ public class NamespaceHttpBasicTests { @@ -325,8 +323,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.httpBasic((httpBasicConfig) ->

6
config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpServerAccessDeniedHandlerTests.java

@ -130,8 +130,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests { @@ -130,8 +130,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().denyAll()
)
.exceptionHandling((exceptionHandling) ->
@ -176,8 +175,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests { @@ -176,8 +175,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().denyAll()
)
.exceptionHandling((exceptionHandling) ->

9
config/src/test/java/org/springframework/security/config/annotation/web/configurers/RememberMeConfigurerTests.java

@ -508,8 +508,7 @@ public class RememberMeConfigurerTests { @@ -508,8 +508,7 @@ public class RememberMeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.formLogin(withDefaults())
@ -557,8 +556,7 @@ public class RememberMeConfigurerTests { @@ -557,8 +556,7 @@ public class RememberMeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.formLogin(withDefaults())
@ -636,8 +634,7 @@ public class RememberMeConfigurerTests { @@ -636,8 +634,7 @@ public class RememberMeConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER")
)
.sessionManagement((sessionManagement) ->

9
config/src/test/java/org/springframework/security/config/annotation/web/configurers/RequestCacheConfigurerTests.java

@ -412,8 +412,7 @@ public class RequestCacheConfigurerTests { @@ -412,8 +412,7 @@ public class RequestCacheConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.formLogin(withDefaults())
@ -432,8 +431,7 @@ public class RequestCacheConfigurerTests { @@ -432,8 +431,7 @@ public class RequestCacheConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.formLogin(withDefaults())
@ -452,8 +450,7 @@ public class RequestCacheConfigurerTests { @@ -452,8 +450,7 @@ public class RequestCacheConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.formLogin(withDefaults())

3
config/src/test/java/org/springframework/security/config/annotation/web/configurers/RequestMatcherConfigurerTests.java

@ -106,8 +106,7 @@ public class RequestMatcherConfigurerTests { @@ -106,8 +106,7 @@ public class RequestMatcherConfigurerTests {
matchers
.requestMatchers(new AntPathRequestMatcher("/oauth/**"))
)
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().denyAll()
);
return http.build();

3
config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurerTests.java

@ -399,8 +399,7 @@ public class OAuth2ClientConfigurerTests { @@ -399,8 +399,7 @@ public class OAuth2ClientConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.oauth2Client(withDefaults());

22
config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java

@ -1395,10 +1395,9 @@ public class OAuth2ResourceServerConfigurerTests { @@ -1395,10 +1395,9 @@ public class OAuth2ResourceServerConfigurerTests {
context.registerBean("converterOne", JwtAuthenticationConverter.class, () -> converterBean);
context.registerBean("converterTwo", JwtAuthenticationConverter.class, () -> converterBean);
this.spring.context(context).autowire();
new OAuth2ResourceServerConfigurer<HttpSecurity>(context).jwt((jwt) -> {
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class)
.isThrownBy(jwt::getJwtAuthenticationConverter);
});
new OAuth2ResourceServerConfigurer<HttpSecurity>(context)
.jwt((jwt) -> assertThatExceptionOfType(NoUniqueBeanDefinitionException.class)
.isThrownBy(jwt::getJwtAuthenticationConverter));
}
@Test
@ -1577,8 +1576,7 @@ public class OAuth2ResourceServerConfigurerTests { @@ -1577,8 +1576,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated()
)
@ -1630,8 +1628,7 @@ public class OAuth2ResourceServerConfigurerTests { @@ -1630,8 +1628,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated()
)
@ -2122,8 +2119,7 @@ public class OAuth2ResourceServerConfigurerTests { @@ -2122,8 +2119,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.oauth2ResourceServer((oauth2ResourceServer) ->
@ -2386,8 +2382,7 @@ public class OAuth2ResourceServerConfigurerTests { @@ -2386,8 +2382,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated()
)
@ -2433,8 +2428,7 @@ public class OAuth2ResourceServerConfigurerTests { @@ -2433,8 +2428,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off
http
.authorizeRequests((authorizeRequests) ->
authorizeRequests
.authorizeRequests((authorize) -> authorize
.anyRequest().authenticated()
)
.oauth2ResourceServer((oauth2ResourceServer) ->

Loading…
Cancel
Save