Skip to content

Commit

Permalink
Make TestCsrfTokenRepository delegate to the actual CsrfTokenReposito…
Browse files Browse the repository at this point in the history
…ry configured in CsrfFilter
  • Loading branch information
chschu committed Apr 26, 2023
1 parent e57e8b3 commit 9a736dd
Showing 1 changed file with 1 addition and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
import org.springframework.security.web.csrf.CsrfTokenRepository;
import org.springframework.security.web.csrf.CsrfTokenRequestHandler;
import org.springframework.security.web.csrf.DeferredCsrfToken;
import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.RequestPostProcessor;
Expand Down Expand Up @@ -517,7 +516,7 @@ public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request)
CsrfTokenRepository repository = WebTestUtils.getCsrfTokenRepository(request);
CsrfTokenRequestHandler handler = WebTestUtils.getCsrfTokenRequestHandler(request);
if (!(repository instanceof TestCsrfTokenRepository)) {
repository = new TestCsrfTokenRepository(new HttpSessionCsrfTokenRepository());
repository = new TestCsrfTokenRepository(repository);
WebTestUtils.setCsrfTokenRepository(request, repository);
}
TestCsrfTokenRepository.enable(request);
Expand Down

0 comments on commit 9a736dd

Please sign in to comment.