@@ -521,8 +521,7 @@ public void loginWhenXorCsrfTokenRequestAttributeHandlerSetAndMaskedCsrfTokenThe
521
521
}
522
522
523
523
@ Test
524
- public void loginWhenFormLoginAndCookieCsrfTokenRepositorySetAndExistingTokenThenRemovesAndGeneratesNewToken ()
525
- throws Exception {
524
+ public void loginWhenFormLoginAndCookieCsrfTokenRepositorySetAndExistingTokenThenRemoves () throws Exception {
526
525
CsrfToken csrfToken = new DefaultCsrfToken ("X-XSRF-TOKEN" , "_csrf" , "token" );
527
526
Cookie existingCookie = new Cookie ("XSRF-TOKEN" , csrfToken .getToken ());
528
527
CookieCsrfTokenRepository csrfTokenRepository = CookieCsrfTokenRepository .withHttpOnlyFalse ();
@@ -541,13 +540,12 @@ public void loginWhenFormLoginAndCookieCsrfTokenRepositorySetAndExistingTokenThe
541
540
MvcResult mvcResult = this .mvc .perform (loginRequest ).andExpect (redirectedUrl ("/" )).andReturn ();
542
541
List <Cookie > cookies = Arrays .asList (mvcResult .getResponse ().getCookies ());
543
542
cookies .removeIf ((cookie ) -> !cookie .getName ().equalsIgnoreCase (existingCookie .getName ()));
544
- assertThat (cookies ).hasSize (2 );
543
+ assertThat (cookies ).hasSize (1 );
545
544
assertThat (cookies .get (0 ).getValue ()).isEmpty ();
546
- assertThat (cookies .get (1 ).getValue ()).isNotEmpty ();
547
545
}
548
546
549
547
@ Test
550
- public void postWhenHttpBasicAndCookieCsrfTokenRepositorySetAndExistingTokenThenRemovesAndGeneratesNewToken ()
548
+ public void postWhenHttpBasicAndCookieCsrfTokenRepositorySetAndExistingTokenThenDoesNotGenerateNewToken ()
551
549
throws Exception {
552
550
CsrfToken csrfToken = new DefaultCsrfToken ("X-XSRF-TOKEN" , "_csrf" , "token" );
553
551
Cookie existingCookie = new Cookie ("XSRF-TOKEN" , csrfToken .getToken ());
@@ -569,13 +567,11 @@ public void postWhenHttpBasicAndCookieCsrfTokenRepositorySetAndExistingTokenThen
569
567
// @formatter:on
570
568
List <Cookie > cookies = Arrays .asList (mvcResult .getResponse ().getCookies ());
571
569
cookies .removeIf ((cookie ) -> !cookie .getName ().equalsIgnoreCase (existingCookie .getName ()));
572
- assertThat (cookies ).hasSize (2 );
573
- assertThat (cookies .get (0 ).getValue ()).isEmpty ();
574
- assertThat (cookies .get (1 ).getValue ()).isNotEmpty ();
570
+ assertThat (cookies ).isEmpty ();
575
571
}
576
572
577
573
@ Test
578
- public void getWhenHttpBasicAndCookieCsrfTokenRepositorySetAndNoExistingCookieThenGeneratesNewToken ()
574
+ public void getWhenHttpBasicAndCookieCsrfTokenRepositorySetAndNoExistingCookieThenDoesNotGenerateNewToken ()
579
575
throws Exception {
580
576
CsrfToken csrfToken = new DefaultCsrfToken ("X-XSRF-TOKEN" , "_csrf" , "token" );
581
577
Cookie expectedCookie = new Cookie ("XSRF-TOKEN" , csrfToken .getToken ());
@@ -596,8 +592,7 @@ public void getWhenHttpBasicAndCookieCsrfTokenRepositorySetAndNoExistingCookieTh
596
592
// @formatter:on
597
593
List <Cookie > cookies = Arrays .asList (mvcResult .getResponse ().getCookies ());
598
594
cookies .removeIf ((cookie ) -> !cookie .getName ().equalsIgnoreCase (expectedCookie .getName ()));
599
- assertThat (cookies ).hasSize (1 );
600
- assertThat (cookies .get (0 ).getValue ()).isNotEmpty ();
595
+ assertThat (cookies ).isEmpty ();
601
596
}
602
597
603
598
@ Configuration
0 commit comments