Search in sources :

Example 31 with ServletRequest

use of jakarta.servlet.ServletRequest in project spring-security by spring-projects.

the class JaasApiIntegrationFilterTests method assertJaasSubjectEquals.

private void assertJaasSubjectEquals(final Subject expectedValue) throws Exception {
    MockFilterChain chain = new MockFilterChain() {

        @Override
        public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
            // See if the subject was updated
            Subject currentSubject = Subject.getSubject(AccessController.getContext());
            assertThat(currentSubject).isEqualTo(expectedValue);
            // run so we know the chain was executed
            super.doFilter(request, response);
        }
    };
    this.filter.doFilter(this.request, this.response, chain);
    // ensure that the chain was actually invoked
    assertThat(chain.getRequest()).isNotNull();
}
Also used : ServletRequest(jakarta.servlet.ServletRequest) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ServletResponse(jakarta.servlet.ServletResponse) MockFilterChain(org.springframework.mock.web.MockFilterChain) Subject(javax.security.auth.Subject)

Aggregations

ServletRequest (jakarta.servlet.ServletRequest)31 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)20 ServletResponse (jakarta.servlet.ServletResponse)16 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)15 ServletException (jakarta.servlet.ServletException)9 IOException (java.io.IOException)9 Test (org.junit.jupiter.api.Test)6 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)5 Request (org.apache.catalina.connector.Request)4 MockFilterChain (org.springframework.mock.web.MockFilterChain)4 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)4 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)4 ServletRequestWrapper (jakarta.servlet.ServletRequestWrapper)3 RequestDataValueProcessor (org.springframework.web.servlet.support.RequestDataValueProcessor)3 HttpSession (jakarta.servlet.http.HttpSession)2 Principal (java.security.Principal)2 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 Context (org.apache.catalina.Context)2