Search in sources :

Example 16 with User

use of keywhiz.auth.User in project keywhiz by square.

the class LdapAuthenticatorTest method ldapAuthenticatorRejectsEmptyPassword.

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

Example 17 with User

use of keywhiz.auth.User in project keywhiz by square.

the class CookieRenewingFilterTest method setsAllNewCookieWithValidCookie.

@Test
public void setsAllNewCookieWithValidCookie() throws Exception {
    User user = User.named("username");
    when(request.getCookies()).thenReturn(ImmutableMap.of(SESSION_COOKIE, cookie));
    when(authenticator.authenticate(cookie)).thenReturn(Optional.of(user));
    NewCookie newCookie1 = new NewCookie(SESSION_COOKIE, "new session");
    when(sessionLoginResource.cookiesForUser(user)).thenReturn(ImmutableList.of(newCookie1));
    filter.filter(request, response);
    assertThat(getCookieMap(response)).contains(entry(newCookie1.getName(), newCookie1.getValue()));
}
Also used : User(keywhiz.auth.User) NewCookie(javax.ws.rs.core.NewCookie) Test(org.junit.Test)

Aggregations

User (keywhiz.auth.User)17 Test (org.junit.Test)13 BasicCredentials (io.dropwizard.auth.basic.BasicCredentials)8 Ignore (org.junit.Ignore)4 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)2 LDAPException (com.unboundid.ldap.sdk.LDAPException)2 GeneralSecurityException (java.security.GeneralSecurityException)2 ForbiddenException (javax.ws.rs.ForbiddenException)2 Cookie (javax.ws.rs.core.Cookie)2 NewCookie (javax.ws.rs.core.NewCookie)2 Response (javax.ws.rs.core.Response)1 SessionCookie (keywhiz.auth.cookie.SessionCookie)1 Request (okhttp3.Request)1 Response (okhttp3.Response)1