Search in sources :

Example 21 with AuthenticationClient

use of co.cask.cdap.security.authentication.client.AuthenticationClient in project cdap-ingest by caskdata.

the class RestStreamClientTest method testSuccessAuthCreate.

@Test
public void testSuccessAuthCreate() throws IOException {
    AuthenticationClient authClient = Mockito.mock(AuthenticationClient.class);
    AccessToken accessToken = Mockito.mock(AccessToken.class);
    Mockito.when(authClient.getAccessToken()).thenReturn(accessToken);
    Mockito.when(accessToken.getValue()).thenReturn(AUTH_TOKEN);
    Mockito.when(accessToken.getTokenType()).thenReturn("Bearer");
    streamClient = RestStreamClient.builder(testServerHost, testServerPort).authClient(authClient).build();
    streamClient.create(TestUtils.SUCCESS_STREAM_NAME);
}
Also used : AccessToken(co.cask.cdap.security.authentication.client.AccessToken) AuthenticationClient(co.cask.cdap.security.authentication.client.AuthenticationClient) Test(org.junit.Test)

Aggregations

AuthenticationClient (co.cask.cdap.security.authentication.client.AuthenticationClient)21 AccessToken (co.cask.cdap.security.authentication.client.AccessToken)16 Test (org.junit.Test)15 HttpFailureException (co.cask.cdap.common.http.exception.HttpFailureException)10 BasicAuthenticationClient (co.cask.cdap.security.authentication.client.basic.BasicAuthenticationClient)5 Properties (java.util.Properties)4 RestStreamClient (co.cask.cdap.client.rest.RestStreamClient)2 ExecutionException (java.util.concurrent.ExecutionException)2 StreamClient (co.cask.cdap.client.StreamClient)1 ConnectionConfig (co.cask.cdap.client.config.ConnectionConfig)1 UnauthenticatedException (co.cask.cdap.common.UnauthenticatedException)1 Credential (co.cask.cdap.security.authentication.client.Credential)1 UnauthorizedException (co.cask.cdap.security.spi.authorization.UnauthorizedException)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1 ConsoleReader (jline.console.ConsoleReader)1