Search in sources :

Example 1 with MockAuthenticationHandler

use of nl.knaw.huygens.security.client.MockAuthenticationHandler in project timbuctoo by HuygensING.

the class LoggedInUsersTest method setUp.

@Before
public void setUp() throws Exception {
    Authenticator authenticator = AuthenticatorMockBuilder.authenticator().withPidFor("a", "b", "pid").build();
    UserStore userStore = userStore().withUserFor("pid").build();
    MockAuthenticationHandler authHandler = new MockAuthenticationHandler();
    userStoreWithUserA = new LoggedInUsers(authenticator, userStore, ONE_SECOND_TIMEOUT, x -> {
        throw new UnauthorizedException();
    });
    Authenticator authenticator1 = AuthenticatorMockBuilder.authenticator().withPidFor("a", "b", "pid").withPidFor("c", "d", "otherPid").build();
    UserStore userStore1 = userStore().withUserFor("pid").withUserFor("otherPid").build();
    userStoreWithUserAAndB = new LoggedInUsers(authenticator1, userStore1, ONE_SECOND_TIMEOUT, x -> {
        throw new UnauthorizedException();
    });
}
Also used : Timeout(nl.knaw.huygens.timbuctoo.util.Timeout) UnauthorizedException(nl.knaw.huygens.security.client.UnauthorizedException) Matchers.not(org.hamcrest.Matchers.not) Test(org.junit.Test) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) AuthenticationUnavailableException(nl.knaw.huygens.timbuctoo.security.exceptions.AuthenticationUnavailableException) LocalLoginUnavailableException(nl.knaw.huygens.timbuctoo.security.exceptions.LocalLoginUnavailableException) User(nl.knaw.huygens.timbuctoo.v5.security.dto.User) Rule(org.junit.Rule) BDDMockito.given(org.mockito.BDDMockito.given) MockAuthenticationHandler(nl.knaw.huygens.security.client.MockAuthenticationHandler) Is.is(org.hamcrest.core.Is.is) Optional(java.util.Optional) OptionalPresentMatcher.present(nl.knaw.huygens.hamcrest.OptionalPresentMatcher.present) UserStoreMockBuilder.userStore(nl.knaw.huygens.timbuctoo.security.UserStoreMockBuilder.userStore) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ExpectedException(org.junit.rules.ExpectedException) SECONDS(java.util.concurrent.TimeUnit.SECONDS) Before(org.junit.Before) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Mockito.mock(org.mockito.Mockito.mock) MockAuthenticationHandler(nl.knaw.huygens.security.client.MockAuthenticationHandler) UnauthorizedException(nl.knaw.huygens.security.client.UnauthorizedException) Before(org.junit.Before)

Aggregations

Optional (java.util.Optional)1 SECONDS (java.util.concurrent.TimeUnit.SECONDS)1 OptionalPresentMatcher.present (nl.knaw.huygens.hamcrest.OptionalPresentMatcher.present)1 MockAuthenticationHandler (nl.knaw.huygens.security.client.MockAuthenticationHandler)1 UnauthorizedException (nl.knaw.huygens.security.client.UnauthorizedException)1 UserStoreMockBuilder.userStore (nl.knaw.huygens.timbuctoo.security.UserStoreMockBuilder.userStore)1 AuthenticationUnavailableException (nl.knaw.huygens.timbuctoo.security.exceptions.AuthenticationUnavailableException)1 LocalLoginUnavailableException (nl.knaw.huygens.timbuctoo.security.exceptions.LocalLoginUnavailableException)1 Timeout (nl.knaw.huygens.timbuctoo.util.Timeout)1 User (nl.knaw.huygens.timbuctoo.v5.security.dto.User)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)1 Matchers.not (org.hamcrest.Matchers.not)1 Is.is (org.hamcrest.core.Is.is)1 Before (org.junit.Before)1 Rule (org.junit.Rule)1 Test (org.junit.Test)1 ExpectedException (org.junit.rules.ExpectedException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 BDDMockito.given (org.mockito.BDDMockito.given)1