Search in sources :

Example 6 with AccessToken

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

the class RESTClientTest method testGetUnauthorizedWithAccessToken.

@Test(expected = UnauthenticatedException.class)
public void testGetUnauthorizedWithAccessToken() throws Exception {
    URL url = getBaseURI().resolve("/api/testGetAuth").toURL();
    HttpRequest request = HttpRequest.get(url).build();
    restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) URL(java.net.URL) Test(org.junit.Test)

Example 7 with AccessToken

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

the class RESTClientTest method testPostForbidden.

@Test(expected = UnauthorizedException.class)
public void testPostForbidden() throws Exception {
    URL url = getBaseURI().resolve("/api/testPostForbidden").toURL();
    HttpRequest request = HttpRequest.post(url).build();
    restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) URL(java.net.URL) Test(org.junit.Test)

Example 8 with AccessToken

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

the class RESTClientTest method testGetForbidden.

@Test(expected = UnauthorizedException.class)
public void testGetForbidden() throws Exception {
    URL url = getBaseURI().resolve("/api/testGetForbidden").toURL();
    HttpRequest request = HttpRequest.get(url).build();
    restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) URL(java.net.URL) Test(org.junit.Test)

Example 9 with AccessToken

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

the class RESTClientTest method testDeleteSuccessWithAccessToken.

@Test
public void testDeleteSuccessWithAccessToken() throws Exception {
    URL url = getBaseURI().resolve("/api/testDeleteAuth").toURL();
    HttpRequest request = HttpRequest.delete(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 10 with AccessToken

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

the class RESTClientTest method testDeleteUnauthorizedWithAccessToken.

@Test(expected = UnauthenticatedException.class)
public void testDeleteUnauthorizedWithAccessToken() throws Exception {
    URL url = getBaseURI().resolve("/api/testDeleteAuth").toURL();
    HttpRequest request = HttpRequest.delete(url).build();
    restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
Also used : FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) HttpRequest(io.cdap.common.http.HttpRequest) AccessToken(io.cdap.cdap.security.authentication.client.AccessToken) 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