Format Lambda Usage

This commit updates Lambda DSL usage to favor
having the variable and reference on the same line

Issue gh-13067
This commit is contained in:
Josh Cummings 2025-06-19 18:16:20 -06:00
parent 777447e1d9
commit da6c7b8759
No known key found for this signature in database
GPG Key ID: 869B37A20E876129
35 changed files with 97 additions and 194 deletions

View File

@ -74,8 +74,7 @@ public class HelloRSocketITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -87,8 +87,7 @@ public class HelloRSocketObservationITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -74,8 +74,7 @@ public class HelloRSocketWithWebFluxITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -86,8 +86,7 @@ public class JwtITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -81,8 +81,7 @@ public class RSocketMessageHandlerConnectionITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -79,8 +79,7 @@ public class RSocketMessageHandlerITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -79,8 +79,7 @@ public class SimpleAuthenticationITests {
// @formatter:off // @formatter:off
this.server = RSocketServer.create() this.server = RSocketServer.create()
.payloadDecoder(PayloadDecoder.ZERO_COPY) .payloadDecoder(PayloadDecoder.ZERO_COPY)
.interceptors((registry) -> .interceptors((registry) -> registry.forSocketAcceptor(this.interceptor)
registry.forSocketAcceptor(this.interceptor)
) )
.acceptor(this.handler.responder()) .acceptor(this.handler.responder())
.bind(TcpServerTransport.create("localhost", 0)) .bind(TcpServerTransport.create("localhost", 0))

View File

@ -129,8 +129,7 @@ public class AnonymousConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.anonymous((anonymous) -> .anonymous((anonymous) -> anonymous
anonymous
.principal("principal") .principal("principal")
); );
return http.build(); return http.build();

View File

@ -186,8 +186,7 @@ public class ChannelSecurityConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.requiresChannel((requiresChannel) -> .requiresChannel((requiresChannel) -> requiresChannel
requiresChannel
.anyRequest().requiresSecure() .anyRequest().requiresSecure()
); );
return http.build(); return http.build();

View File

@ -128,8 +128,7 @@ public class CsrfConfigurerIgnoringRequestMatchersTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.csrf((csrf) -> .csrf((csrf) -> csrf
csrf
.requireCsrfProtectionMatcher(new AntPathRequestMatcher("/path")) .requireCsrfProtectionMatcher(new AntPathRequestMatcher("/path"))
.ignoringRequestMatchers(this.requestMatcher) .ignoringRequestMatchers(this.requestMatcher)
); );
@ -169,8 +168,7 @@ public class CsrfConfigurerIgnoringRequestMatchersTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.csrf((csrf) -> .csrf((csrf) -> csrf
csrf
.ignoringRequestMatchers(new AntPathRequestMatcher("/no-csrf")) .ignoringRequestMatchers(new AntPathRequestMatcher("/no-csrf"))
.ignoringRequestMatchers(this.requestMatcher) .ignoringRequestMatchers(this.requestMatcher)
); );

View File

@ -116,8 +116,7 @@ public class ExceptionHandlingConfigurerAccessDeniedHandlerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.exceptionHandling((exceptionHandling) -> .exceptionHandling((exceptionHandling) -> exceptionHandling
exceptionHandling
.defaultAccessDeniedHandlerFor( .defaultAccessDeniedHandlerFor(
this.teapotDeniedHandler, this.teapotDeniedHandler,
new AntPathRequestMatcher("/hello/**") new AntPathRequestMatcher("/hello/**")

View File

@ -518,8 +518,7 @@ public class FormLoginConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.formLogin((formLogin) -> .formLogin((formLogin) -> formLogin
formLogin
.loginPage("/authenticate") .loginPage("/authenticate")
.permitAll() .permitAll()
) )
@ -573,15 +572,13 @@ public class FormLoginConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.formLogin((formLogin) -> .formLogin((formLogin) -> formLogin
formLogin
.loginProcessingUrl("/loginCheck") .loginProcessingUrl("/loginCheck")
.loginPage("/login") .loginPage("/login")
.defaultSuccessUrl("/", true) .defaultSuccessUrl("/", true)
.permitAll() .permitAll()
) )
.logout((logout) -> .logout((logout) -> logout
logout
.logoutSuccessUrl("/login") .logoutSuccessUrl("/login")
.logoutUrl("/logout") .logoutUrl("/logout")
.deleteCookies("JSESSIONID") .deleteCookies("JSESSIONID")

View File

@ -630,8 +630,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.contentTypeOptions(withDefaults()) .contentTypeOptions(withDefaults())
); );
@ -700,8 +699,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.cacheControl(withDefaults()) .cacheControl(withDefaults())
); );
@ -753,8 +751,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.xssProtection(withDefaults()) .xssProtection(withDefaults())
); );
@ -772,11 +769,9 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.xssProtection((xXssConfig) -> .xssProtection((xXssConfig) -> xXssConfig.headerValue(XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK)
xXssConfig.headerValue(XXssProtectionHeaderWriter.HeaderValue.ENABLED_MODE_BLOCK)
) )
); );
// @formatter:on // @formatter:on
@ -808,8 +803,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.frameOptions((frameOptionsConfig) -> frameOptionsConfig.sameOrigin()) .frameOptions((frameOptionsConfig) -> frameOptionsConfig.sameOrigin())
); );
return http.build(); return http.build();
@ -976,11 +970,9 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.httpPublicKeyPinning((hpkp) -> .httpPublicKeyPinning((hpkp) -> hpkp
hpkp
.addSha256Pins("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=") .addSha256Pins("d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=")
.reportUri("https://example.net/pkp-report") .reportUri("https://example.net/pkp-report")
) )
@ -1035,11 +1027,9 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.contentSecurityPolicy((csp) -> .contentSecurityPolicy((csp) -> csp
csp
.policyDirectives("default-src 'self'; script-src trustedscripts.example.com") .policyDirectives("default-src 'self'; script-src trustedscripts.example.com")
.reportOnly() .reportOnly()
) )
@ -1075,11 +1065,9 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.contentSecurityPolicy((csp) -> .contentSecurityPolicy((csp) -> csp.policyDirectives("")
csp.policyDirectives("")
) )
); );
return http.build(); return http.build();
@ -1096,8 +1084,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.contentSecurityPolicy(withDefaults()) .contentSecurityPolicy(withDefaults())
); );
@ -1132,8 +1119,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.referrerPolicy(Customizer.withDefaults()) .referrerPolicy(Customizer.withDefaults())
); );
@ -1168,11 +1154,9 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.referrerPolicy((referrerPolicy) -> .referrerPolicy((referrerPolicy) -> referrerPolicy.policy(ReferrerPolicy.SAME_ORIGIN)
referrerPolicy.policy(ReferrerPolicy.SAME_ORIGIN)
) )
); );
return http.build(); return http.build();
@ -1308,8 +1292,7 @@ public class HeadersConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.headers((headers) -> .headers((headers) -> headers
headers
.defaultsDisabled() .defaultsDisabled()
.httpStrictTransportSecurity((hstsConfig) -> hstsConfig.preload(true)) .httpStrictTransportSecurity((hstsConfig) -> hstsConfig.preload(true))
); );

View File

@ -336,8 +336,7 @@ public class HttpSecurityRequestMatchersTests {
SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospector introspector) throws Exception { SecurityFilterChain filterChain(HttpSecurity http, HandlerMappingIntrospector introspector) throws Exception {
// @formatter:off // @formatter:off
http http
.securityMatchers((matchers) -> .securityMatchers((secure) -> secure
matchers
.requestMatchers(new MvcRequestMatcher(introspector, "/path")) .requestMatchers(new MvcRequestMatcher(introspector, "/path"))
) )
.httpBasic(withDefaults()) .httpBasic(withDefaults())
@ -409,8 +408,7 @@ public class HttpSecurityRequestMatchersTests {
mvcMatcherBuilder.servletPath("/spring"); mvcMatcherBuilder.servletPath("/spring");
// @formatter:off // @formatter:off
http http
.securityMatchers((matchers) -> .securityMatchers((secure) -> secure
matchers
.requestMatchers(mvcMatcherBuilder.pattern("/path")) .requestMatchers(mvcMatcherBuilder.pattern("/path"))
.requestMatchers("/never-match") .requestMatchers("/never-match")
) )

View File

@ -212,8 +212,7 @@ public class JeeConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.jee((jee) -> .jee((jee) -> jee
jee
.mappableRoles("USER") .mappableRoles("USER")
); );
return http.build(); return http.build();
@ -233,8 +232,7 @@ public class JeeConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.jee((jee) -> .jee((jee) -> jee
jee
.mappableAuthorities("ROLE_USER") .mappableAuthorities("ROLE_USER")
); );
return http.build(); return http.build();
@ -257,8 +255,7 @@ public class JeeConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.jee((jee) -> .jee((jee) -> jee
jee
.authenticatedUserDetailsService(authenticationUserDetailsService) .authenticatedUserDetailsService(authenticationUserDetailsService)
); );
return http.build(); return http.build();

View File

@ -431,8 +431,7 @@ public class LogoutConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.logout((logout) -> .logout((logout) -> logout.defaultLogoutSuccessHandlerFor(null, mock(RequestMatcher.class))
logout.defaultLogoutSuccessHandlerFor(null, mock(RequestMatcher.class))
); );
return http.build(); return http.build();
// @formatter:on // @formatter:on
@ -464,8 +463,7 @@ public class LogoutConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.logout((logout) -> .logout((logout) -> logout.defaultLogoutSuccessHandlerFor(mock(LogoutSuccessHandler.class), null)
logout.defaultLogoutSuccessHandlerFor(mock(LogoutSuccessHandler.class), null)
); );
return http.build(); return http.build();
// @formatter:on // @formatter:on

View File

@ -280,8 +280,7 @@ public class NamespaceHttpBasicTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.httpBasic((httpBasicConfig) -> .httpBasic((httpBasicConfig) -> httpBasicConfig.authenticationDetailsSource(this.authenticationDetailsSource));
httpBasicConfig.authenticationDetailsSource(this.authenticationDetailsSource));
return http.build(); return http.build();
// @formatter:on // @formatter:on
} }
@ -326,8 +325,7 @@ public class NamespaceHttpBasicTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.httpBasic((httpBasicConfig) -> .httpBasic((httpBasicConfig) -> httpBasicConfig.authenticationEntryPoint(this.authenticationEntryPoint));
httpBasicConfig.authenticationEntryPoint(this.authenticationEntryPoint));
return http.build(); return http.build();
// @formatter:on // @formatter:on
} }

View File

@ -215,8 +215,7 @@ public class NamespaceHttpLogoutTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.logout((logout) -> .logout((logout) -> logout.deleteCookies("remove")
logout.deleteCookies("remove")
.invalidateHttpSession(false) .invalidateHttpSession(false)
.logoutUrl("/custom-logout") .logoutUrl("/custom-logout")
.logoutSuccessUrl("/logout-success") .logoutSuccessUrl("/logout-success")

View File

@ -133,8 +133,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.exceptionHandling((exceptionHandling) -> .exceptionHandling((exceptionHandling) -> exceptionHandling.accessDeniedPage("/AccessDeniedPageConfig")
exceptionHandling.accessDeniedPage("/AccessDeniedPageConfig")
); );
return http.build(); return http.build();
// @formatter:on // @formatter:on
@ -178,8 +177,7 @@ public class NamespaceHttpServerAccessDeniedHandlerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().denyAll() .anyRequest().denyAll()
) )
.exceptionHandling((exceptionHandling) -> .exceptionHandling((exceptionHandling) -> exceptionHandling.accessDeniedHandler(accessDeniedHandler())
exceptionHandling.accessDeniedHandler(accessDeniedHandler())
); );
return http.build(); return http.build();
// @formatter:on // @formatter:on

View File

@ -93,12 +93,10 @@ public class PortMapperConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.requiresChannel((requiresChannel) -> .requiresChannel((requiresChannel) -> requiresChannel
requiresChannel
.anyRequest().requiresSecure() .anyRequest().requiresSecure()
) )
.portMapper((portMapper) -> .portMapper((portMapper) -> portMapper
portMapper
.http(543).mapsTo(123) .http(543).mapsTo(123)
); );
return http.build(); return http.build();
@ -117,12 +115,10 @@ public class PortMapperConfigurerTests {
customPortMapper.setPortMappings(Collections.singletonMap("543", "123")); customPortMapper.setPortMappings(Collections.singletonMap("543", "123"));
// @formatter:off // @formatter:off
http http
.requiresChannel((requiresChannel) -> .requiresChannel((requiresChannel) -> requiresChannel
requiresChannel
.anyRequest().requiresSecure() .anyRequest().requiresSecure()
) )
.portMapper((portMapper) -> .portMapper((portMapper) -> portMapper
portMapper
.portMapper(customPortMapper) .portMapper(customPortMapper)
); );
return http.build(); return http.build();

View File

@ -560,8 +560,7 @@ public class RememberMeConfigurerTests {
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.formLogin(withDefaults()) .formLogin(withDefaults())
.rememberMe((rememberMe) -> .rememberMe((rememberMe) -> rememberMe
rememberMe
.rememberMeCookieDomain("spring.io") .rememberMeCookieDomain("spring.io")
); );
return http.build(); return http.build();
@ -637,8 +636,7 @@ public class RememberMeConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().hasRole("USER") .anyRequest().hasRole("USER")
) )
.sessionManagement((sessionManagement) -> .sessionManagement((sessionManagement) -> sessionManagement
sessionManagement
.maximumSessions(1) .maximumSessions(1)
) )
.formLogin(withDefaults()) .formLogin(withDefaults())

View File

@ -454,8 +454,7 @@ public class RequestCacheConfigurerTests {
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.formLogin(withDefaults()) .formLogin(withDefaults())
.requestCache((requestCache) -> .requestCache((requestCache) -> requestCache
requestCache
.requestCache(new NullRequestCache()) .requestCache(new NullRequestCache())
); );
return http.build(); return http.build();

View File

@ -98,12 +98,10 @@ public class RequestMatcherConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.securityMatchers((matchers) -> .securityMatchers((secure) -> secure
matchers
.requestMatchers(new AntPathRequestMatcher("/api/**")) .requestMatchers(new AntPathRequestMatcher("/api/**"))
) )
.securityMatchers((matchers) -> .securityMatchers((securityMatchers) -> securityMatchers
matchers
.requestMatchers(new AntPathRequestMatcher("/oauth/**")) .requestMatchers(new AntPathRequestMatcher("/oauth/**"))
) )
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize

View File

@ -269,8 +269,7 @@ public class SecurityContextConfigurerTests {
// @formatter:off // @formatter:off
http http
.formLogin(withDefaults()) .formLogin(withDefaults())
.securityContext((securityContext) -> .securityContext((securityContext) -> securityContext
securityContext
.securityContextRepository(new NullSecurityContextRepository()) .securityContextRepository(new NullSecurityContextRepository())
); );
// @formatter:on // @formatter:on

View File

@ -359,8 +359,7 @@ public class ServletApiConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.servletApi((servletApi) -> .servletApi((servletApi) -> servletApi
servletApi
.rolePrefix("PERMISSION_") .rolePrefix("PERMISSION_")
); );
return http.build(); return http.build();

View File

@ -629,8 +629,7 @@ public class SessionManagementConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.sessionManagement((sessionManagement) -> .sessionManagement((sessionManagement) -> sessionManagement
sessionManagement
.requireExplicitAuthenticationStrategy(false) .requireExplicitAuthenticationStrategy(false)
.sessionFixation(SessionManagementConfigurer.SessionFixationConfigurer::newSession) .sessionFixation(SessionManagementConfigurer.SessionFixationConfigurer::newSession)
) )
@ -678,10 +677,8 @@ public class SessionManagementConfigurerTests {
// @formatter:off // @formatter:off
http http
.formLogin(withDefaults()) .formLogin(withDefaults())
.sessionManagement((sessionManagement) -> .sessionManagement((sessionManagement) -> sessionManagement
sessionManagement .sessionConcurrency((sessionConcurrency) -> sessionConcurrency
.sessionConcurrency((sessionConcurrency) ->
sessionConcurrency
.maximumSessions(1) .maximumSessions(1)
.maxSessionsPreventsLogin(true) .maxSessionsPreventsLogin(true)
) )
@ -741,8 +738,7 @@ public class SessionManagementConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.sessionManagement((sessionManagement) -> .sessionManagement((sessionManagement) -> sessionManagement
sessionManagement
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
); );
return http.build(); return http.build();
@ -897,8 +893,7 @@ public class SessionManagementConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.sessionManagement((sessionManagement) -> .sessionManagement((sessionManagement) -> sessionManagement
sessionManagement
.sessionCreationPolicy(SessionCreationPolicy.STATELESS) .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
) )
.httpBasic(withDefaults()); .httpBasic(withDefaults());

View File

@ -280,8 +280,7 @@ public class X509ConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.x509((x509) -> .x509((x509) -> x509
x509
.subjectPrincipalRegex("CN=(.*?)@example.com(?:,|$)") .subjectPrincipalRegex("CN=(.*?)@example.com(?:,|$)")
); );
// @formatter:on // @formatter:on

View File

@ -827,8 +827,7 @@ public class OAuth2LoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login
.clientRegistrationRepository( .clientRegistrationRepository(
new InMemoryClientRegistrationRepository(GOOGLE_CLIENT_REGISTRATION)) new InMemoryClientRegistrationRepository(GOOGLE_CLIENT_REGISTRATION))
); );
@ -1029,11 +1028,9 @@ public class OAuth2LoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login
.clientRegistrationRepository(this.clientRegistrationRepository) .clientRegistrationRepository(this.clientRegistrationRepository)
.authorizationEndpoint((authorizationEndpoint) -> .authorizationEndpoint((authorizationEndpoint) -> authorizationEndpoint
authorizationEndpoint
.authorizationRequestResolver(this.resolver) .authorizationRequestResolver(this.resolver)
) )
); );
@ -1056,11 +1053,9 @@ public class OAuth2LoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login
.clientRegistrationRepository(this.clientRegistrationRepository) .clientRegistrationRepository(this.clientRegistrationRepository)
.authorizationEndpoint((authorizationEndpoint) -> .authorizationEndpoint((authorizationEndpoint) -> authorizationEndpoint
authorizationEndpoint
.authorizationRedirectStrategy(this.redirectStrategy) .authorizationRedirectStrategy(this.redirectStrategy)
) )
); );
@ -1083,11 +1078,9 @@ public class OAuth2LoginConfigurerTests {
SecurityFilterChain configureFilterChain(HttpSecurity http) throws Exception { SecurityFilterChain configureFilterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login
.clientRegistrationRepository(this.clientRegistrationRepository) .clientRegistrationRepository(this.clientRegistrationRepository)
.authorizationEndpoint((authorizationEndpoint) -> .authorizationEndpoint((authorizationEndpoint) -> authorizationEndpoint
authorizationEndpoint
.authorizationRedirectStrategy(this.redirectStrategy) .authorizationRedirectStrategy(this.redirectStrategy)
) )
); );
@ -1159,8 +1152,7 @@ public class OAuth2LoginConfigurerTests {
SecurityFilterChain filterChain(HttpSecurity http) throws Exception { SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// @formatter:off // @formatter:off
http http
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login
.clientRegistrationRepository( .clientRegistrationRepository(
new InMemoryClientRegistrationRepository(GOOGLE_CLIENT_REGISTRATION)) new InMemoryClientRegistrationRepository(GOOGLE_CLIENT_REGISTRATION))
.loginPage("/custom-login") .loginPage("/custom-login")
@ -1343,18 +1335,14 @@ public class OAuth2LoginConfigurerTests {
.authorizeHttpRequests((authorize) -> authorize .authorizeHttpRequests((authorize) -> authorize
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.securityContext((securityContext) -> .securityContext((securityContext) -> securityContext
securityContext
.securityContextRepository(securityContextRepository()) .securityContextRepository(securityContextRepository())
) )
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login .tokenEndpoint((tokenEndpoint) -> tokenEndpoint
.tokenEndpoint((tokenEndpoint) ->
tokenEndpoint
.accessTokenResponseClient(createOauth2AccessTokenResponseClient()) .accessTokenResponseClient(createOauth2AccessTokenResponseClient())
) )
.userInfoEndpoint((userInfoEndpoint) -> .userInfoEndpoint((userInfoEndpoint) -> userInfoEndpoint
userInfoEndpoint
.userService(createOauth2UserService()) .userService(createOauth2UserService())
.oidcUserService(createOidcUserService()) .oidcUserService(createOidcUserService())
) )

View File

@ -245,8 +245,7 @@ public class DPoPAuthenticationConfigurerTests {
.requestMatchers("/resource2").hasAnyAuthority("SCOPE_resource2.read", "SCOPE_resource2.write") .requestMatchers("/resource2").hasAnyAuthority("SCOPE_resource2.read", "SCOPE_resource2.write")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer
.jwt(Customizer.withDefaults())); .jwt(Customizer.withDefaults()));
// @formatter:on // @formatter:on
return http.build(); return http.build();

View File

@ -1580,8 +1580,7 @@ public class OAuth2ResourceServerConfigurerTests {
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')") .requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer
.jwt(withDefaults()) .jwt(withDefaults())
); );
return http.build(); return http.build();
@ -1632,10 +1631,8 @@ public class OAuth2ResourceServerConfigurerTests {
.requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')") .requestMatchers("/requires-read-scope").access("hasAuthority('SCOPE_message:read')")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .jwt((jwt) -> jwt
.jwt((jwt) ->
jwt
.jwkSetUri(this.jwkSetUri) .jwkSetUri(this.jwkSetUri)
) )
); );
@ -2122,10 +2119,8 @@ public class OAuth2ResourceServerConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .jwt((jwt) -> jwt
.jwt((jwt) ->
jwt
.decoder(decoder()) .decoder(decoder())
) )
); );
@ -2386,8 +2381,7 @@ public class OAuth2ResourceServerConfigurerTests {
.requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read") .requestMatchers("/requires-read-scope").hasAuthority("SCOPE_message:read")
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer
.opaqueToken(withDefaults()) .opaqueToken(withDefaults())
); );
return http.build(); return http.build();
@ -2431,10 +2425,8 @@ public class OAuth2ResourceServerConfigurerTests {
.authorizeRequests((authorize) -> authorize .authorizeRequests((authorize) -> authorize
.anyRequest().authenticated() .anyRequest().authenticated()
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .opaqueToken((opaqueToken) -> opaqueToken
.opaqueToken((opaqueToken) ->
opaqueToken
.authenticationManager(authenticationProvider()::authenticate) .authenticationManager(authenticationProvider()::authenticate)
) )
); );

View File

@ -333,8 +333,7 @@ public class HeaderSpecTests {
this.expectedHeaders.set(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "0"); this.expectedHeaders.set(XXssProtectionServerHttpHeadersWriter.X_XSS_PROTECTION, "0");
// @formatter:off // @formatter:off
this.http.headers((headers) -> headers this.http.headers((headers) -> headers
.xssProtection((xssProtection) -> .xssProtection((xssProtection) -> xssProtection.headerValue(XXssProtectionServerHttpHeadersWriter.HeaderValue.DISABLED)
xssProtection.headerValue(XXssProtectionServerHttpHeadersWriter.HeaderValue.DISABLED)
)); ));
// @formatter:on // @formatter:on
assertHeaders(); assertHeaders();

View File

@ -211,8 +211,7 @@ public class HttpsRedirectSpecTests {
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
// @formatter:off // @formatter:off
http http
.redirectToHttps((redirectToHttps) -> .redirectToHttps((redirectToHttps) -> redirectToHttps
redirectToHttps
.httpsRedirectWhen(new PathPatternParserServerWebExchangeMatcher("/secure")) .httpsRedirectWhen(new PathPatternParserServerWebExchangeMatcher("/secure"))
); );
// @formatter:on // @formatter:on
@ -252,8 +251,7 @@ public class HttpsRedirectSpecTests {
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
// @formatter:off // @formatter:off
http http
.redirectToHttps((redirectToHttps) -> .redirectToHttps((redirectToHttps) -> redirectToHttps
redirectToHttps
.portMapper(portMapper()) .portMapper(portMapper())
); );
// @formatter:on // @formatter:on

View File

@ -377,8 +377,7 @@ public class OAuth2ClientSpecTests {
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) { SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
// @formatter:off // @formatter:off
http http
.oauth2Client((oauth2Client) -> .oauth2Client((oauth2Client) -> oauth2Client
oauth2Client
.authenticationConverter(this.authenticationConverter) .authenticationConverter(this.authenticationConverter)
.authenticationManager(this.manager) .authenticationManager(this.manager)
.authorizationRequestRepository(this.authorizationRequestRepository)) .authorizationRequestRepository(this.authorizationRequestRepository))

View File

@ -986,12 +986,10 @@ public class OAuth2LoginTests {
SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) { SecurityWebFilterChain springSecurityFilter(ServerHttpSecurity http) {
// @formatter:off // @formatter:off
http http
.authorizeExchange((exchanges) -> .authorizeExchange((authorizeExchange) -> authorizeExchange
exchanges
.anyExchange().authenticated() .anyExchange().authenticated()
) )
.oauth2Login((oauth2Login) -> .oauth2Login((oauth2) -> oauth2
oauth2Login
.authenticationConverter(this.authenticationConverter) .authenticationConverter(this.authenticationConverter)
.authenticationManager(this.manager) .authenticationManager(this.manager)
.authenticationMatcher(this.matcher) .authenticationMatcher(this.matcher)

View File

@ -701,14 +701,11 @@ public class OAuth2ResourceServerSpecTests {
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
// @formatter:off // @formatter:off
http http
.authorizeExchange((exchanges) -> .authorizeExchange((authorizeExchange) -> authorizeExchange
exchanges
.anyExchange().hasAuthority("SCOPE_message:read") .anyExchange().hasAuthority("SCOPE_message:read")
) )
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .jwt((jwt) -> jwt
.jwt((jwt) ->
jwt
.publicKey(publicKey()) .publicKey(publicKey())
) )
); );
@ -782,10 +779,8 @@ public class OAuth2ResourceServerSpecTests {
String jwkSetUri = mockWebServer().url("/.well-known/jwks.json").toString(); String jwkSetUri = mockWebServer().url("/.well-known/jwks.json").toString();
// @formatter:off // @formatter:off
http http
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .jwt((jwt) -> jwt
.jwt((jwt) ->
jwt
.jwkSetUri(jwkSetUri) .jwkSetUri(jwkSetUri)
) )
); );
@ -879,10 +874,8 @@ public class OAuth2ResourceServerSpecTests {
SecurityWebFilterChain springSecurity(ServerHttpSecurity http) { SecurityWebFilterChain springSecurity(ServerHttpSecurity http) {
// @formatter:off // @formatter:off
http http
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .jwt((jwt) -> jwt
.jwt((jwt) ->
jwt
.authenticationManager(authenticationManager()) .authenticationManager(authenticationManager())
) )
); );
@ -1078,10 +1071,8 @@ public class OAuth2ResourceServerSpecTests {
String introspectionUri = mockWebServer().url("/introspect").toString(); String introspectionUri = mockWebServer().url("/introspect").toString();
// @formatter:off // @formatter:off
http http
.oauth2ResourceServer((oauth2ResourceServer) -> .oauth2ResourceServer((oauth2) -> oauth2
oauth2ResourceServer .opaqueToken((opaqueToken) -> opaqueToken
.opaqueToken((opaqueToken) ->
opaqueToken
.introspectionUri(introspectionUri) .introspectionUri(introspectionUri)
.introspectionClientCredentials("client", "secret") .introspectionClientCredentials("client", "secret")
) )