Search in sources :

Example 6 with BasicCredentials

use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.

the class BcryptAuthenticatorTest method bcryptAuthenticatorRejectsInvalidUsername.

@Test
public void bcryptAuthenticatorRejectsInvalidUsername() throws Exception {
    String crazyUsername = "sysadmin)`~!@#$%^&*()+=[]{}\\|;:'\",<>?/\r\n\t";
    Optional<User> missingUser = bcryptAuthenticator.authenticate(new BasicCredentials(crazyUsername, "validpass"));
    assertThat(missingUser.isPresent()).isFalse();
}
Also used : User(keywhiz.auth.User) BasicCredentials(io.dropwizard.auth.basic.BasicCredentials) Test(org.junit.Test)

Example 7 with BasicCredentials

use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.

the class LdapAuthenticatorTest method ldapAuthenticatorRejectsEmptyPassword.

@Test
public void ldapAuthenticatorRejectsEmptyPassword() throws Exception {
    Optional<User> user = ldapAuthenticator.authenticate(new BasicCredentials("sysadmin", ""));
    assertThat(user.isPresent()).isFalse();
}
Also used : User(keywhiz.auth.User) BasicCredentials(io.dropwizard.auth.basic.BasicCredentials) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with BasicCredentials

use of io.dropwizard.auth.basic.BasicCredentials in project keywhiz by square.

the class LdapAuthenticatorTest method ldapAuthenticatorThrowsWhenAuthFails.

@Test
public void ldapAuthenticatorThrowsWhenAuthFails() throws Exception {
    // Zero results on a search indicates no valid user.
    when(dnSearchResult.getEntryCount()).thenReturn(0);
    Optional<User> missingUser = ldapAuthenticator.authenticate(new BasicCredentials("sysadmin", "badpass"));
    assertThat(missingUser.isPresent()).isFalse();
}
Also used : User(keywhiz.auth.User) BasicCredentials(io.dropwizard.auth.basic.BasicCredentials) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

BasicCredentials (io.dropwizard.auth.basic.BasicCredentials)8 User (keywhiz.auth.User)8 Test (org.junit.Test)8 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4