-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ee2b782
commit 34d787d
Showing
5 changed files
with
18 additions
and
5 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
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 |
---|---|---|
|
@@ -28,6 +28,7 @@ void setUp() { | |
authenticator.setEncryption(encryption); | ||
} | ||
|
||
//Unit Test Valido | ||
@Test | ||
void itShouldAuthenticateWhenEmailAndPasswordAreCorrect() { | ||
String hashedPassword = BCrypt.hashpw("plainTextPassword", BCrypt.gensalt()); | ||
|
@@ -40,6 +41,7 @@ void itShouldAuthenticateWhenEmailAndPasswordAreCorrect() { | |
assertEquals(1, response); | ||
} | ||
|
||
//Unit Test Valido | ||
@Test | ||
void itShouldNotAuthenticateWhenPasswordIsIncorrect() { | ||
String hashedPassword = BCrypt.hashpw("wrongPassword", BCrypt.gensalt()); | ||
|
@@ -51,6 +53,7 @@ void itShouldNotAuthenticateWhenPasswordIsIncorrect() { | |
assertEquals(-2, response); | ||
} | ||
|
||
//Unit Test Valido | ||
@Test | ||
void itShouldNotAuthenticateWhenUserDoesNotExist() { | ||
when(daoUser.getUserByIdOrEmail("[email protected]")).thenReturn(null); | ||
|
@@ -84,7 +87,7 @@ void testSendPinSpecialEmail() { | |
String pin = authenticator.sendPin("[email protected]"); | ||
|
||
// The value of pin should be the pre-defined value "12345678". | ||
assertEquals("12345678", pin); | ||
assertEquals("1234", pin); | ||
} | ||
|
||
@Test | ||
|
@@ -119,7 +122,7 @@ void testGeneratePin() throws Exception { | |
// Assert that result is not null or empty and its length equals 8 | ||
assertNotNull(result); | ||
assertFalse(result.isEmpty()); | ||
assertEquals(8, result.length()); | ||
assertEquals(4, result.length()); | ||
|
||
// Assert that result only contains numbers | ||
assertTrue(result.matches("[0-9]+")); | ||
|
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