Search in sources :

Example 11 with SecurityContextRepository

use of org.springframework.security.web.context.SecurityContextRepository in project spring-security by spring-projects.

the class SessionManagementFilterTests method strategyIsNotInvokedIfAuthenticationIsNull.

@Test
public void strategyIsNotInvokedIfAuthenticationIsNull() throws Exception {
    SecurityContextRepository repo = mock(SecurityContextRepository.class);
    SessionAuthenticationStrategy strategy = mock(SessionAuthenticationStrategy.class);
    SessionManagementFilter filter = new SessionManagementFilter(repo, strategy);
    HttpServletRequest request = new MockHttpServletRequest();
    filter.doFilter(request, new MockHttpServletResponse(), new MockFilterChain());
    verifyZeroInteractions(strategy);
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) SessionAuthenticationStrategy(org.springframework.security.web.authentication.session.SessionAuthenticationStrategy) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) SecurityContextRepository(org.springframework.security.web.context.SecurityContextRepository) MockFilterChain(org.springframework.mock.web.MockFilterChain) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.Test)

Aggregations

SecurityContextRepository (org.springframework.security.web.context.SecurityContextRepository)11 Test (org.junit.Test)8 MockFilterChain (org.springframework.mock.web.MockFilterChain)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 SessionAuthenticationStrategy (org.springframework.security.web.authentication.session.SessionAuthenticationStrategy)5 AuthenticationTrustResolver (org.springframework.security.authentication.AuthenticationTrustResolver)3 HttpSessionSecurityContextRepository (org.springframework.security.web.context.HttpSessionSecurityContextRepository)3 FilterChain (javax.servlet.FilterChain)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Authentication (org.springframework.security.core.Authentication)2 AuthenticationFailureHandler (org.springframework.security.web.authentication.AuthenticationFailureHandler)2 NullSecurityContextRepository (org.springframework.security.web.context.NullSecurityContextRepository)2 SessionCreationPolicy (org.springframework.security.config.http.SessionCreationPolicy)1 SimpleUrlAuthenticationFailureHandler (org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler)1 SessionAuthenticationException (org.springframework.security.web.authentication.session.SessionAuthenticationException)1 SecurityContextPersistenceFilter (org.springframework.security.web.context.SecurityContextPersistenceFilter)1 NullRequestCache (org.springframework.security.web.savedrequest.NullRequestCache)1 RequestCache (org.springframework.security.web.savedrequest.RequestCache)1