From 6bbf20be93d6b7c0a393abcfff09f81ee8cd9aad Mon Sep 17 00:00:00 2001 From: Steve Riesenberg Date: Wed, 5 Oct 2022 14:19:11 -0500 Subject: [PATCH] Fix failing tests Issue gh-11952 --- .../security/config/annotation/web/CsrfDslTests.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/src/test/kotlin/org/springframework/security/config/annotation/web/CsrfDslTests.kt b/config/src/test/kotlin/org/springframework/security/config/annotation/web/CsrfDslTests.kt index 0e58cd4f50..c82e756f4c 100644 --- a/config/src/test/kotlin/org/springframework/security/config/annotation/web/CsrfDslTests.kt +++ b/config/src/test/kotlin/org/springframework/security/config/annotation/web/CsrfDslTests.kt @@ -19,6 +19,8 @@ package org.springframework.security.config.annotation.web import io.mockk.every import io.mockk.mockkObject import io.mockk.verify +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import org.springframework.beans.factory.annotation.Autowired @@ -37,17 +39,17 @@ import org.springframework.security.web.SecurityFilterChain import org.springframework.security.web.authentication.session.NullAuthenticatedSessionStrategy import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy import org.springframework.security.web.csrf.CsrfTokenRepository +import org.springframework.security.web.csrf.CsrfTokenRequestAttributeHandler import org.springframework.security.web.csrf.CsrfTokenRequestHandler import org.springframework.security.web.csrf.DefaultCsrfToken import org.springframework.security.web.csrf.HttpSessionCsrfTokenRepository import org.springframework.security.web.util.matcher.AntPathRequestMatcher import org.springframework.test.web.servlet.MockMvc +import org.springframework.test.web.servlet.get import org.springframework.test.web.servlet.post import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RestController import org.springframework.web.servlet.config.annotation.EnableWebMvc -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse /** * Tests for [CsrfDsl] @@ -360,9 +362,7 @@ class CsrfDslTests { open class RequestHandlerConfig { companion object { - val HANDLER: CsrfTokenRequestHandler = CsrfTokenRequestHandler { request, response, _ -> - request.setAttribute(HttpServletResponse::class.java.name, response) - } + var HANDLER: CsrfTokenRequestHandler = CsrfTokenRequestAttributeHandler() } @Bean