Skip to content

Commit

Permalink
#398 fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
kfchu committed May 31, 2018
1 parent e26eab8 commit ef8f72c
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,30 @@ public void testAuthenticateSuccessfully() throws SaturnJobConsoleException {
public void testAuthenticationFailWhenUserIsNotFound() throws SaturnJobConsoleException {
authnService.setHashMethod("plaintext");
when(userRepository.select("john")).thenReturn(null);
boolean hasException = false;
try {
assertNull(authnService.authenticate("john", "password"));
} catch (SaturnJobConsoleException e) {
hasException = true;
assertEquals(SaturnJobConsoleException.ERROR_CODE_AUTHN_FAIL, e.getErrorCode());
}

assertTrue(hasException);

assertNull(authnService.authenticate("john", "password"));
}

@Test
public void testAuthenticationFailWhenPasswordInputIsEmpty() throws SaturnJobConsoleException {
authnService.setHashMethod("plaintext");
assertNull(authnService.authenticate("john", ""));
boolean hasException = false;
try {
authnService.authenticate("john", "");
} catch (SaturnJobConsoleException e) {
hasException = true;
assertEquals(SaturnJobConsoleException.ERROR_CODE_AUTHN_FAIL, e.getErrorCode());
}

assertTrue(hasException);
}

private User createUser(String username, String password) {
Expand Down

0 comments on commit ef8f72c

Please sign in to comment.