Search in sources :

Example 16 with AccessToken

use of io.cdap.cdap.security.authentication.client.AccessToken in project cdap by caskdata.

the class RESTClientTest method testPutSuccessWithAccessToken.

@Test
public void testPutSuccessWithAccessToken() throws Exception {
    URL url = getBaseURI().resolve("/api/testPutAuth").toURL();
    HttpRequest request = HttpRequest.put(url).build();
    HttpResponse response = restClient.execute(request, new AccessToken(ACCESS_TOKEN, 82000L, "Bearer"));
    verifyResponse(response, only(200), any(), only("Access token received: " + ACCESS_TOKEN));
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) HttpResponse(io.cdap.common.http.HttpResponse) URL(java.net.URL) Test(org.junit.Test)

Example 17 with AccessToken

use of io.cdap.cdap.security.authentication.client.AccessToken in project cdap by caskdata.

the class RESTClientTest method testUnavailableLimit.

@Test
public void testUnavailableLimit() throws Exception {
    URL url = getBaseURI().resolve("/api/testUnavail").toURL();
    HttpRequest request = HttpRequest.get(url).build();
    HttpResponse response = restClient.execute(request, new AccessToken(ACCESS_TOKEN, 82000L, "Bearer"));
    verifyResponse(response, only(200), any(), any());
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) HttpResponse(io.cdap.common.http.HttpResponse) URL(java.net.URL) Test(org.junit.Test)

Example 18 with AccessToken

use of io.cdap.cdap.security.authentication.client.AccessToken in project cdap by caskdata.

the class RESTClientTest method testPostSuccessWithAccessToken.

@Test
public void testPostSuccessWithAccessToken() throws Exception {
    URL url = getBaseURI().resolve("/api/testPostAuth").toURL();
    HttpRequest request = HttpRequest.post(url).build();
    HttpResponse response = restClient.execute(request, new AccessToken(ACCESS_TOKEN, 82000L, "Bearer"));
    verifyResponse(response, only(200), any(), only("Access token received: " + ACCESS_TOKEN));
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) HttpResponse(io.cdap.common.http.HttpResponse) URL(java.net.URL) Test(org.junit.Test)

Aggregations

AccessToken (io.cdap.cdap.security.authentication.client.AccessToken)18 URL (java.net.URL)14 Test (org.junit.Test)14 HttpRequest (io.cdap.common.http.HttpRequest)13 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)13 HttpResponse (io.cdap.common.http.HttpResponse)6 ConnectionConfig (io.cdap.cdap.client.config.ConnectionConfig)2 Properties (java.util.Properties)2 DatasetProperties (io.cdap.cdap.api.dataset.DatasetProperties)1 ClientConfig (io.cdap.cdap.client.config.ClientConfig)1 ExploreDriver (io.cdap.cdap.explore.jdbc.ExploreDriver)1 AuthenticationClient (io.cdap.cdap.security.authentication.client.AuthenticationClient)1 Credential (io.cdap.cdap.security.authentication.client.Credential)1 BasicAuthenticationClient (io.cdap.cdap.security.authentication.client.basic.BasicAuthenticationClient)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 HashMap (java.util.HashMap)1 ConsoleReader (jline.console.ConsoleReader)1