Reputation: 225
My tomcat application is refusing to build when I try to launch it on tomcat on the following errors
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 13.603 sec <<< FAILURE!
itShouldAllowAccessToSecuredPageForPermittedUser(ie.claddino.chat.LoginTestCase) Time elapsed: 12.791 sec <<< FAILURE!
java.lang.AssertionError: Status expected:<200> but was:<302>
This is the method that is failing from controller class
@Test
public void itShouldAllowAccessToSecuredPageForPermittedUser() throws Exception {
SecurityContext securityContext = userAuthentication();
MockHttpSession session = new MockHttpSession();
session.setAttribute(HttpSessionSecurityContextRepository.SPRING_SECURITY_CONTEXT_KEY, securityContext);
mockMvc.perform(get(SECURED_URI).session(session))
.andExpect(status().isOk()).andExpect(redirectedUrl(LOGIN_PAGE_URL));
}*
Please what could be wrong with my application? Please does anyone know what status 302 means.
Upvotes: 0
Views: 6897
Reputation: 14572
302 means temporary redirecting request. When there is url redirect to be completed, we can do it using a 302
status code and having the url as a parameter in the header.
Since you are doing a redirection, I think you should expect a 302 response as well. status().isOk()
means 200
status code. Check is there any method for temporary redirect or just put 302 there. hence it can check for 302 code instead of 200.
Upvotes: 0