@@ -69,12 +69,10 @@ public class FormLoginTests {
6969 public void defaultLoginPage () {
7070 // @formatter:off
7171 SecurityWebFilterChain securityWebFilter = this .http
72- .authorizeExchange ()
73- .anyExchange ().authenticated ()
74- .and ()
75- .formLogin ()
76- .and ()
77- .build ();
72+ .authorizeExchange ((exchange ) -> exchange
73+ .anyExchange ().authenticated ())
74+ .formLogin (withDefaults ())
75+ .build ();
7876 WebTestClient webTestClient = WebTestClientBuilder
7977 .bindToWebFilters (securityWebFilter )
8078 .build ();
@@ -129,14 +127,12 @@ public void formLoginWhenDefaultsInLambdaThenCreatesDefaultLoginPage() {
129127 public void customLoginPage () {
130128 // @formatter:off
131129 SecurityWebFilterChain securityWebFilter = this .http
132- .authorizeExchange ()
133- .pathMatchers ("/login" ).permitAll ()
134- .anyExchange ().authenticated ()
135- .and ()
136- .formLogin ()
137- .loginPage ("/login" )
138- .and ()
139- .build ();
130+ .authorizeExchange ((exchange ) -> exchange
131+ .pathMatchers ("/login" ).permitAll ()
132+ .anyExchange ().authenticated ())
133+ .formLogin ((login ) -> login
134+ .loginPage ("/login" ))
135+ .build ();
140136 WebTestClient webTestClient = WebTestClient
141137 .bindToController (new CustomLoginPageController (), new WebTestClientBuilder .Http200RestController ())
142138 .webFilter (new WebFilterChainProxy (securityWebFilter ))
@@ -189,14 +185,12 @@ public void formLoginWhenCustomLoginPageInLambdaThenUsed() {
189185 public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed () {
190186 // @formatter:off
191187 SecurityWebFilterChain securityWebFilter = this .http
192- .authorizeExchange ()
193- .pathMatchers ("/login" , "/failure" ).permitAll ()
194- .anyExchange ().authenticated ()
195- .and ()
196- .formLogin ()
197- .authenticationFailureHandler (new RedirectServerAuthenticationFailureHandler ("/failure" ))
198- .and ()
199- .build ();
188+ .authorizeExchange ((exchange ) -> exchange
189+ .pathMatchers ("/login" , "/failure" ).permitAll ()
190+ .anyExchange ().authenticated ())
191+ .formLogin ((login ) -> login
192+ .authenticationFailureHandler (new RedirectServerAuthenticationFailureHandler ("/failure" )))
193+ .build ();
200194 WebTestClient webTestClient = WebTestClientBuilder
201195 .bindToWebFilters (securityWebFilter )
202196 .build ();
@@ -218,14 +212,12 @@ public void formLoginWhenCustomAuthenticationFailureHandlerThenUsed() {
218212 public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed () {
219213 // @formatter:off
220214 SecurityWebFilterChain securityWebFilter = this .http
221- .authorizeExchange ()
222- .pathMatchers ("/login" , "/sign-in" ).permitAll ()
223- .anyExchange ().authenticated ()
224- .and ()
225- .formLogin ()
226- .requiresAuthenticationMatcher (new PathPatternParserServerWebExchangeMatcher ("/sign-in" ))
227- .and ()
228- .build ();
215+ .authorizeExchange ((exchange ) -> exchange
216+ .pathMatchers ("/login" , "/sign-in" ).permitAll ()
217+ .anyExchange ().authenticated ())
218+ .formLogin ((login ) -> login
219+ .requiresAuthenticationMatcher (new PathPatternParserServerWebExchangeMatcher ("/sign-in" )))
220+ .build ();
229221 WebTestClient webTestClient = WebTestClientBuilder
230222 .bindToWebFilters (securityWebFilter )
231223 .build ();
@@ -241,13 +233,11 @@ public void formLoginWhenCustomRequiresAuthenticationMatcherThenUsed() {
241233 public void authenticationSuccess () {
242234 // @formatter:off
243235 SecurityWebFilterChain securityWebFilter = this .http
244- .authorizeExchange ()
245- .anyExchange ().authenticated ()
246- .and ()
247- .formLogin ()
248- .authenticationSuccessHandler (new RedirectServerAuthenticationSuccessHandler ("/custom" ))
249- .and ()
250- .build ();
236+ .authorizeExchange ((exchange ) -> exchange
237+ .anyExchange ().authenticated ())
238+ .formLogin ((login ) -> login
239+ .authenticationSuccessHandler (new RedirectServerAuthenticationSuccessHandler ("/custom" )))
240+ .build ();
251241 WebTestClient webTestClient = WebTestClientBuilder
252242 .bindToWebFilters (securityWebFilter )
253243 .build ();
@@ -275,11 +265,10 @@ public void customAuthenticationManager() {
275265 .willReturn (Mono .just (new TestingAuthenticationToken ("user" , "password" , "ROLE_USER" , "ROLE_ADMIN" )));
276266 // @formatter:off
277267 SecurityWebFilterChain securityWebFilter = this .http
278- .authenticationManager (defaultAuthenticationManager )
279- .formLogin ()
280- .authenticationManager (customAuthenticationManager )
281- .and ()
282- .build ();
268+ .authenticationManager (defaultAuthenticationManager )
269+ .formLogin ((login ) -> login
270+ .authenticationManager (customAuthenticationManager ))
271+ .build ();
283272 WebTestClient webTestClient = WebTestClientBuilder
284273 .bindToWebFilters (securityWebFilter )
285274 .build ();
@@ -309,14 +298,12 @@ public void formLoginSecurityContextRepository() {
309298 given (formLoginSecContextRepository .load (any ())).willReturn (authentication (token ));
310299 // @formatter:off
311300 SecurityWebFilterChain securityWebFilter = this .http
312- .authorizeExchange ()
313- .anyExchange ().authenticated ()
314- .and ()
315- .securityContextRepository (defaultSecContextRepository )
316- .formLogin ()
317- .securityContextRepository (formLoginSecContextRepository )
318- .and ()
319- .build ();
301+ .authorizeExchange ((exchange ) -> exchange
302+ .anyExchange ().authenticated ())
303+ .securityContextRepository (defaultSecContextRepository )
304+ .formLogin ((login ) -> login
305+ .securityContextRepository (formLoginSecContextRepository ))
306+ .build ();
320307 WebTestClient webTestClient = WebTestClientBuilder
321308 .bindToWebFilters (securityWebFilter )
322309 .build ();
0 commit comments