use of org.springframework.mock.web.MockHttpSession in project spring-security-oauth by spring-projects.
the class HttpSessionOAuthRememberMeServicesTests method testNoTokensRemembered.
@Test
public void testNoTokensRemembered() {
MockHttpSession mockHttpSession = new MockHttpSession();
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
request.setSession(mockHttpSession);
HttpSessionOAuthRememberMeServices oAuthRememberMeService = new HttpSessionOAuthRememberMeServices();
Map<String, OAuthConsumerToken> tokens = new HashMap<String, OAuthConsumerToken>();
oAuthRememberMeService.rememberTokens(tokens, request, response);
Assert.assertEquals(0, oAuthRememberMeService.loadRememberedTokens(request, response).size());
}
use of org.springframework.mock.web.MockHttpSession in project spring-security by spring-projects.
the class HttpNamespaceWithMultipleInterceptorsTests method createAuthenticatedSession.
public HttpSession createAuthenticatedSession(String... roles) {
MockHttpSession session = new MockHttpSession();
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("bob", "bobspassword", roles));
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
SecurityContextHolder.clearContext();
return session;
}
use of org.springframework.mock.web.MockHttpSession in project spring-security by spring-projects.
the class HttpPathParameterStrippingTests method createAuthenticatedSession.
public HttpSession createAuthenticatedSession(String... roles) {
MockHttpSession session = new MockHttpSession();
SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("bob", "bobspassword", roles));
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
SecurityContextHolder.clearContext();
return session;
}
use of org.springframework.mock.web.MockHttpSession in project spring-security by spring-projects.
the class FilterChainPerformanceTests method createAuthenticatedSession.
@Before
public void createAuthenticatedSession() {
session = new MockHttpSession();
SecurityContextHolder.getContext().setAuthentication(user);
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, SecurityContextHolder.getContext());
SecurityContextHolder.clearContext();
}
use of org.springframework.mock.web.MockHttpSession in project spring-security by spring-projects.
the class HttpSessionEventPublisherTests method sessionCreatedNullApplicationContext.
// SEC-2599
@Test(expected = IllegalStateException.class)
public void sessionCreatedNullApplicationContext() {
HttpSessionEventPublisher publisher = new HttpSessionEventPublisher();
MockServletContext servletContext = new MockServletContext();
MockHttpSession session = new MockHttpSession(servletContext);
HttpSessionEvent event = new HttpSessionEvent(session);
publisher.sessionCreated(event);
}
Aggregations