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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -106,8 +106,7 @@ public class RequestMatcherConfigurerTests {
matchers matchers
.requestMatchers(new AntPathRequestMatcher("/oauth/**")) .requestMatchers(new AntPathRequestMatcher("/oauth/**"))
) )
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().denyAll() .anyRequest().denyAll()
); );
return http.build(); 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 {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2Client(withDefaults()); .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 {
context.registerBean("converterOne", JwtAuthenticationConverter.class, () -> converterBean); context.registerBean("converterOne", JwtAuthenticationConverter.class, () -> converterBean);
context.registerBean("converterTwo", JwtAuthenticationConverter.class, () -> converterBean); context.registerBean("converterTwo", JwtAuthenticationConverter.class, () -> converterBean);
this.spring.context(context).autowire(); this.spring.context(context).autowire();
new OAuth2ResourceServerConfigurer<HttpSecurity>(context).jwt((jwt) -> { new OAuth2ResourceServerConfigurer<HttpSecurity>(context)
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class) .jwt((jwt) -> assertThatExceptionOfType(NoUniqueBeanDefinitionException.class)
.isThrownBy(jwt::getJwtAuthenticationConverter); .isThrownBy(jwt::getJwtAuthenticationConverter));
});
} }
@Test @Test
@ -1577,8 +1576,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')") .requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
@ -1630,8 +1628,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')") .requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
@ -2122,8 +2119,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2ResourceServer) ->
@ -2386,8 +2382,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read") .requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
@ -2433,8 +2428,7 @@ public class OAuth2ResourceServerConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.authorizeRequests((authorizeRequests) -> .authorizeRequests((authorize) -> authorize
authorizeRequests
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2ResourceServer) ->

Loading…
Cancel
Save