Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ public PasswordResetRequest build() {
checkArgumentNotNull(getInstance().requester, "Requester must be specified");
checkArgumentNotNull(getInstance().destinationEmail, "Destination email must be specified");
checkArgumentNotNull(getInstance().registrarId, "Registrar ID must be specified");
getInstance().verificationCode = UUID.randomUUID().toString();
if (getInstance().verificationCode == null) {
getInstance().verificationCode = UUID.randomUUID().toString();
}
return super.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ void testSuccess_post_lock() throws Exception {
.isTrue();
}

@Test
void testFailure_post_replay() throws Exception {
createAction("POST", verificationCode, "newPassword1").run();
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_OK);

// Attempting to reuse the same code should fail
createAction("POST", verificationCode, "newPassword2").run();
assertThat(response.getStatus()).isEqualTo(HttpServletResponse.SC_BAD_REQUEST);
}

@Test
void testFailure_get_invalidVerificationCode() throws Exception {
createAction("GET", "invalid", null).run();
Expand Down
Loading