@Test public void testResetPassword() throws Exception { String username = "******"; User user = userManager.getUserByUsername(username); String token = userManager.generateRecoveryToken(user); String password = "******"; Wiser wiser = startWiser(getSmtpPort()); ResultActions update = mockMvc .perform( post("/updatePassword") .param("username", username) .param("token", token) .param("password", password)) .andExpect(status().is3xxRedirection()) .andExpect(redirectedUrl("/")); wiser.stop(); assertTrue(wiser.getMessages().size() == 1); MvcResult result = update.andReturn(); MockHttpSession session = (MockHttpSession) result.getRequest().getSession(); assertNotNull(session.getAttribute(BaseFormController.MESSAGES_KEY)); assertNull(session.getAttribute(BaseFormController.ERRORS_MESSAGES_KEY)); }
@Test public void testShowResetPasswordForm() throws Exception { String username = "******"; User user = userManager.getUserByUsername(username); String token = userManager.generateRecoveryToken(user); ResultActions update = mockMvc .perform(get("/updatePassword").param("username", username).param("token", token)) .andExpect(status().isOk()) .andExpect(view().name("updatePasswordForm")); MvcResult result = update.andReturn(); MockHttpSession session = (MockHttpSession) result.getRequest().getSession(); assertNull(session.getAttribute(BaseFormController.ERRORS_MESSAGES_KEY)); }