-
Notifications
You must be signed in to change notification settings - Fork 546
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: simplifying email verification token creation (#1016)
* #334 - simplify email verification token creation * Update tests.yml updating github action `checkout` to version 4 * reverting workflow modifications * #334 - simplify email verification token creation tests * chore: bumping version number, writing changelog
- Loading branch information
1 parent
2f99bf9
commit 43a5a68
Showing
3 changed files
with
70 additions
and
14 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
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 |
---|---|---|
|
@@ -238,7 +238,7 @@ public void testFormatOfEmailVerificationToken() throws Exception { | |
String verifyToken = EmailVerification.generateEmailVerificationToken(process.getProcess(), | ||
user.getSupertokensUserId(), | ||
user.loginMethods[0].email); | ||
assertEquals(verifyToken.length(), 128); | ||
assertEquals(128, verifyToken.length()); | ||
assertFalse(verifyToken.contains("+")); | ||
assertFalse(verifyToken.contains("=")); | ||
assertFalse(verifyToken.contains("/")); | ||
|
@@ -316,6 +316,36 @@ public void verifyEmail() throws Exception { | |
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); | ||
} | ||
|
||
@Test | ||
public void verifyEmailWithOldTokenAfterTokenGenerationChanged() throws Exception { | ||
String[] args = {"../"}; | ||
|
||
TestingProcessManager.TestingProcess process = TestingProcessManager.start(args); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STARTED)); | ||
|
||
if (StorageLayer.getStorage(process.getProcess()).getType() != STORAGE_TYPE.SQL) { | ||
return; | ||
} | ||
|
||
AuthRecipeUserInfo user = EmailPassword.signUp(process.getProcess(), "[email protected]", "password"); | ||
|
||
assert (!EmailVerification.isEmailVerified(process.getProcess(), user.getSupertokensUserId(), | ||
user.loginMethods[0].email)); | ||
|
||
String token = EmailVerification.generateEmailVerificationTokenTheOldWay(process.getProcess(), | ||
user.getSupertokensUserId(), user.loginMethods[0].email); | ||
|
||
assert (token != null); | ||
|
||
EmailVerification.verifyEmail(process.getProcess(), token); | ||
|
||
assert (EmailVerification.isEmailVerified(process.getProcess(), user.getSupertokensUserId(), | ||
user.loginMethods[0].email)); | ||
|
||
process.kill(); | ||
assertNotNull(process.checkOrWaitForEvent(ProcessState.PROCESS_STATE.STOPPED)); | ||
} | ||
|
||
// Verify the email successfully, then unverify and check that its unverified | ||
@Test | ||
public void testVerifyingEmailAndThenUnverify() throws Exception { | ||
|