use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class SecurityMockMvcRequestPostProcessorsCertificateTests method x509ResourceName.
@Test
public void x509ResourceName() throws Exception {
MockHttpServletRequest postProcessedRequest = x509("rod.cer").postProcessRequest(request);
X509Certificate[] certificates = (X509Certificate[]) postProcessedRequest.getAttribute("javax.servlet.request.X509Certificate");
assertThat(certificates.length).isEqualTo(1);
assertThat(certificates[0].getSubjectDN().getName()).isEqualTo("CN=rod, OU=Spring Security, O=Spring Framework");
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class SecurityMockMvcRequestPostProcessorsCsrfDebugFilterTests method findCookieCsrfTokenRepository.
// SEC-3836
@Test
public void findCookieCsrfTokenRepository() throws Exception {
MockHttpServletRequest request = post("/").buildRequest(wac.getServletContext());
CsrfTokenRepository csrfTokenRepository = WebTestUtils.getCsrfTokenRepository(request);
assertThat(csrfTokenRepository).isNotNull();
assertThat(csrfTokenRepository).isEqualTo(Config.cookieCsrfTokenRepository);
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class SecurityMockMvcRequestPostProcessorsDigestTests method digestWithFilterCustomUsername.
@Test
public void digestWithFilterCustomUsername() throws Exception {
String username = "admin";
MockHttpServletRequest postProcessedRequest = digest(username).postProcessRequest(request);
assertThat(extractUser()).isEqualTo(username);
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class SecurityMockMvcRequestPostProcessorsDigestTests method setup.
@Before
public void setup() {
this.password = "password";
request = new MockHttpServletRequest();
entryPoint = new DigestAuthenticationEntryPoint();
entryPoint.setKey("key");
entryPoint.setRealmName("Spring Security");
filter = new DigestAuthenticationFilter();
filter.setUserDetailsService(new UserDetailsService() {
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
return new User(username, password, AuthorityUtils.createAuthorityList("ROLE_USER"));
}
});
filter.setAuthenticationEntryPoint(entryPoint);
filter.afterPropertiesSet();
}
use of org.springframework.mock.web.MockHttpServletRequest in project spring-security by spring-projects.
the class AbstractAuthorizeTagTests method setup.
@Before
public void setup() {
tag = new AuthzTag();
request = new MockHttpServletRequest();
response = new MockHttpServletResponse();
servletContext = new MockServletContext();
}
Aggregations