use of org.springframework.mock.web.MockHttpServletRequest in project cas by apereo.
the class ServiceThemeResolverTests method verifyGetDefaultServiceWithNoServicesManager.
@Test
public void verifyGetDefaultServiceWithNoServicesManager() {
this.serviceThemeResolver = new ServiceThemeResolver(DEFAULT_THEME_NAME, null, mobileBrowsers);
final MockHttpServletRequest request = new MockHttpServletRequest();
request.setParameter("service", "myServiceId");
request.addHeader(WebUtils.USER_AGENT_HEADER, MOZILLA);
assertEquals(DEFAULT_THEME_NAME, this.serviceThemeResolver.resolveThemeName(request));
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class CasAuthenticationFilterTests method testAuthenticateProxyUrl.
@Test
public void testAuthenticateProxyUrl() throws Exception {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
request.setServletPath("/pgtCallback");
filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
filter.setProxyReceptorUrl(request.getServletPath());
assertThat(filter.attemptAuthentication(request, response)).isNull();
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class CasAuthenticationFilterTests method testChainNotInvokedForProxyReceptor.
// SEC-1592
@Test
public void testChainNotInvokedForProxyReceptor() throws Exception {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
FilterChain chain = mock(FilterChain.class);
request.setServletPath("/pgtCallback");
filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
filter.setProxyReceptorUrl(request.getServletPath());
filter.doFilter(request, response, chain);
verifyZeroInteractions(chain);
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class CasAuthenticationFilterTests method testRequiresAuthenticationProxyRequest.
@Test
public void testRequiresAuthenticationProxyRequest() {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = new MockHttpServletResponse();
request.setServletPath("/pgtCallback");
assertThat(filter.requiresAuthentication(request, response)).isFalse();
filter.setProxyReceptorUrl(request.getServletPath());
assertThat(filter.requiresAuthentication(request, response)).isFalse();
filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
assertThat(filter.requiresAuthentication(request, response)).isTrue();
request.setServletPath("/other");
assertThat(filter.requiresAuthentication(request, response)).isFalse();
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class CasAuthenticationFilterTests method testNullServiceTicketHandledGracefully.
@Test(expected = AuthenticationException.class)
public void testNullServiceTicketHandledGracefully() throws Exception {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setAuthenticationManager(new AuthenticationManager() {
public Authentication authenticate(Authentication a) {
throw new BadCredentialsException("Rejected");
}
});
filter.attemptAuthentication(new MockHttpServletRequest(), new MockHttpServletResponse());
}
Aggregations