Search in sources :

Example 1 with Clock

use of com.opentext.ia.sdk.support.datetime.Clock in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenConfiguringAuthenticationStrategy method shouldGetJwtAuthentication.

@Test
public void shouldGetJwtAuthentication() {
    configuration.setClientId(randomString());
    configuration.setClientSecret(randomString());
    configuration.setAuthenticationGateway(randomString());
    configuration.setAuthenticationUser(randomString());
    configuration.setAuthenticationPassword(randomString());
    HttpClient httpClient = mock(HttpClient.class);
    Clock clock = mock(Clock.class);
    AuthenticationStrategy authentication = authFactory.getAuthenticationStrategy(() -> httpClient, () -> clock);
    assertTrue(authentication instanceof JwtAuthentication);
}
Also used : HttpClient(com.opentext.ia.sdk.support.http.HttpClient) AuthenticationStrategy(com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy) Clock(com.opentext.ia.sdk.support.datetime.Clock) JwtAuthentication(com.opentext.ia.sdk.support.http.rest.JwtAuthentication) Test(org.junit.Test)

Example 2 with Clock

use of com.opentext.ia.sdk.support.datetime.Clock in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenConfiguringAuthenticationStrategy method shouldThrowException.

@Test(expected = IllegalArgumentException.class)
public void shouldThrowException() {
    configuration.setClientId(randomString());
    configuration.setClientSecret(randomString());
    configuration.setAuthenticationGateway(randomString());
    configuration.setAuthenticationUser(randomString());
    HttpClient httpClient = mock(HttpClient.class);
    Clock clock = mock(Clock.class);
    authFactory.getAuthenticationStrategy(() -> httpClient, () -> clock);
}
Also used : HttpClient(com.opentext.ia.sdk.support.http.HttpClient) Clock(com.opentext.ia.sdk.support.datetime.Clock) Test(org.junit.Test)

Example 3 with Clock

use of com.opentext.ia.sdk.support.datetime.Clock in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenCreatingAuthenticationStrategy method shouldNotConfigureJwtAuthentication.

@Test
public void shouldNotConfigureJwtAuthentication() {
    String username = randomString();
    String password = randomString();
    HttpClient httpClient = mock(HttpClient.class);
    Clock clock = mock(Clock.class);
    assertFalse("Should not configure JwtAuthentication because of abscence of gatewayInfo", JwtAuthentication.optional(username, password, null, httpClient, clock).isPresent());
}
Also used : HttpClient(com.opentext.ia.sdk.support.http.HttpClient) Clock(com.opentext.ia.sdk.support.datetime.Clock) Test(org.junit.Test)

Example 4 with Clock

use of com.opentext.ia.sdk.support.datetime.Clock in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenCreatingAuthenticationStrategy method shouldConfigureJwtAuthentication.

@Test
public void shouldConfigureJwtAuthentication() {
    String username = randomString();
    String password = randomString();
    Optional<GatewayInfo> gatewayInfo = GatewayInfo.optional(randomString(), randomString(), randomString());
    HttpClient httpClient = mock(HttpClient.class);
    Clock clock = mock(Clock.class);
    assertTrue("Should configure JwtAuthentication", JwtAuthentication.optional(username, password, gatewayInfo.orElse(null), httpClient, clock).isPresent());
}
Also used : HttpClient(com.opentext.ia.sdk.support.http.HttpClient) Clock(com.opentext.ia.sdk.support.datetime.Clock) Test(org.junit.Test)

Example 5 with Clock

use of com.opentext.ia.sdk.support.datetime.Clock in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class ArchiveClients method configuringServerUsing.

/**
   * Returns an ArchiveClient instance and configures the InfoArchive server that it communicates with.
   * @param configurer How to configure InfoArchive
   * @param optionalClient The REST client to use for communication with the server
   * @param optionalClock The clock to use
   * @return An ArchiveClient
   */
public static ArchiveClient configuringServerUsing(InfoArchiveConfigurer configurer, RestClient optionalClient, Clock optionalClock) {
    ServerConfiguration serverConfiguration = configurer.getServerConfiguration();
    Clock clock = Optional.ofNullable(optionalClock).orElseGet(DefaultClock::new);
    RestClient client = Optional.ofNullable(optionalClient).orElseGet(() -> createRestClient(serverConfiguration, clock));
    configurer.configure();
    return usingAlreadyConfiguredServer(serverConfiguration, client, clock);
}
Also used : DefaultClock(com.opentext.ia.sdk.support.datetime.DefaultClock) ServerConfiguration(com.opentext.ia.sdk.client.api.ServerConfiguration) InfoArchiveRestClient(com.opentext.ia.sdk.client.impl.InfoArchiveRestClient) RestClient(com.opentext.ia.sdk.support.http.rest.RestClient) Clock(com.opentext.ia.sdk.support.datetime.Clock) DefaultClock(com.opentext.ia.sdk.support.datetime.DefaultClock)

Aggregations

Clock (com.opentext.ia.sdk.support.datetime.Clock)6 HttpClient (com.opentext.ia.sdk.support.http.HttpClient)4 Test (org.junit.Test)4 InfoArchiveRestClient (com.opentext.ia.sdk.client.impl.InfoArchiveRestClient)2 DefaultClock (com.opentext.ia.sdk.support.datetime.DefaultClock)2 RestClient (com.opentext.ia.sdk.support.http.rest.RestClient)2 ServerConfiguration (com.opentext.ia.sdk.client.api.ServerConfiguration)1 AuthenticationStrategy (com.opentext.ia.sdk.support.http.rest.AuthenticationStrategy)1 JwtAuthentication (com.opentext.ia.sdk.support.http.rest.JwtAuthentication)1