use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.
the class BcryptAuthenticatorTest method bcryptAuthenticatorCreatesUserOnSuccess.
@Test
public void bcryptAuthenticatorCreatesUserOnSuccess() throws Exception {
when(userDAO.getHashedPassword("sysadmin")).thenReturn(Optional.of(hashedPass));
User user = bcryptAuthenticator.authenticate(new BasicCredentials("sysadmin", "validpass")).orElseThrow(RuntimeException::new);
assertThat(user).isEqualTo(User.named("sysadmin"));
}
use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.
the class LdapAuthenticatorTest method ldapAuthenticatorRejectsInvalidUsername.
@Test
public void ldapAuthenticatorRejectsInvalidUsername() throws Exception {
String crazyUsername = "sysadmin)`~!@#$%^&*()+=[]{}\\|;:'\",<>?/\r\n\t";
Optional<User> missingUser = ldapAuthenticator.authenticate(new BasicCredentials(crazyUsername, "badpass"));
assertThat(missingUser.isPresent()).isFalse();
}
use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.
the class LdapAuthenticatorTest method ldapAuthenticatorCreatesUserOnSuccess.
@Test
public void ldapAuthenticatorCreatesUserOnSuccess() throws Exception {
when(ldapConnectionFactory.getLDAPConnection(PEOPLE_DN, "validpass")).thenReturn(ldapUserAuthConnection);
User user = ldapAuthenticator.authenticate(new BasicCredentials("sysadmin", "validpass")).orElseThrow(RuntimeException::new);
assertThat(user).isEqualTo(User.named("sysadmin"));
}
use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.
the class BcryptAuthenticatorTest method bcryptAuthenticatorFailsForBadPassword.
@Test
public void bcryptAuthenticatorFailsForBadPassword() throws Exception {
when(userDAO.getHashedPassword("sysadmin")).thenReturn(Optional.of(hashedPass));
Optional<User> missingUser = bcryptAuthenticator.authenticate(new BasicCredentials("sysadmin", "badpass"));
assertThat(missingUser.isPresent()).isFalse();
}
use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.
the class BcryptAuthenticatorTest method bcryptAuthenticatorFailsForBadUser.
@Test
public void bcryptAuthenticatorFailsForBadUser() throws Exception {
when(userDAO.getHashedPassword("invaliduser")).thenReturn(Optional.empty());
Optional<User> missingUser = bcryptAuthenticator.authenticate(new BasicCredentials("invaliduser", "validpass"));
assertThat(missingUser.isPresent()).isFalse();
}
Aggregations