-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip reset password requests with HEAD method
- Loading branch information
1 parent
862eb92
commit 3800fc7
Showing
2 changed files
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
import static org.mockito.Mockito.*; | ||
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.head; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; | ||
|
@@ -282,6 +283,21 @@ void testResetPasswordPage() throws Exception { | |
.andExpect(content().string(containsString("<input type=\"hidden\" name=\"username\" value=\"username\"/>"))); | ||
} | ||
|
||
@Test | ||
void testResetPasswordPageWithPriorHeadRequest() throws Exception { | ||
ExpiringCode code = codeStore.generateCode("{\"user_id\" : \"some-user-id\"}", new Timestamp(System.currentTimeMillis() + 1000000), null, IdentityZoneHolder.get().getId()); | ||
mockMvc.perform(head("/reset_password").param("email", "[email protected]").param("code", code.getCode())) | ||
.andExpect(status().isOk()); | ||
mockMvc.perform(get("/reset_password").param("email", "[email protected]").param("code", code.getCode())) | ||
.andExpect(status().isOk()) | ||
.andDo(print()) | ||
.andExpect(view().name("reset_password")) | ||
.andExpect(model().attribute("email", "email")) | ||
.andExpect(model().attribute("username", "username")) | ||
.andExpect(content().string(containsString("<div class=\"email-display\">Username: username</div>"))) | ||
.andExpect(content().string(containsString("<input type=\"hidden\" name=\"username\" value=\"username\"/>"))); | ||
} | ||
|
||
@Test | ||
void testResetPasswordPageDuplicate() throws Exception { | ||
ExpiringCode code = codeStore.generateCode("{\"user_id\" : \"some-user-id\"}", new Timestamp(System.currentTimeMillis() + 1000000), null, IdentityZoneHolder.get().getId()); | ||
|