use of co.cask.cdap.security.authentication.client.AccessToken in project cdap by caskdata.
the class RESTClientTest method testPutUnauthorizedWithAccessToken.
@Test(expected = UnauthenticatedException.class)
public void testPutUnauthorizedWithAccessToken() throws Exception {
URL url = getBaseURI().resolve("/api/testPutAuth").toURL();
HttpRequest request = HttpRequest.put(url).build();
restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
use of co.cask.cdap.security.authentication.client.AccessToken in project cdap by caskdata.
the class RESTClientTest method testPostUnauthorizedWithAccessToken.
@Test(expected = UnauthenticatedException.class)
public void testPostUnauthorizedWithAccessToken() throws Exception {
URL url = getBaseURI().resolve("/api/testPostAuth").toURL();
HttpRequest request = HttpRequest.post(url).build();
restClient.execute(request, new AccessToken("Unknown", 82000L, "Bearer"));
}
use of co.cask.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"));
}
use of co.cask.cdap.security.authentication.client.AccessToken in project cdap by caskdata.
the class RESTClientTest method testGetSuccessWithAccessToken.
@Test
public void testGetSuccessWithAccessToken() throws Exception {
URL url = getBaseURI().resolve("/api/testGetAuth").toURL();
HttpRequest request = HttpRequest.get(url).build();
HttpResponse response = restClient.execute(request, new AccessToken(ACCESS_TOKEN, 82000L, "Bearer"));
verifyResponse(response, only(200), any(), only("Access token received: " + ACCESS_TOKEN));
}
use of co.cask.cdap.security.authentication.client.AccessToken in project cdap-ingest by caskdata.
the class RestStreamWriterTest method testNotAuthorizedEmptyTokenStringWrite.
@Test
public void testNotAuthorizedEmptyTokenStringWrite() throws IOException, InterruptedException {
AuthenticationClient authClient = Mockito.mock(AuthenticationClient.class);
AccessToken accessToken = Mockito.mock(AccessToken.class);
Mockito.when(authClient.getAccessToken()).thenReturn(accessToken);
Mockito.when(accessToken.getValue()).thenReturn(StringUtils.EMPTY);
Mockito.when(accessToken.getTokenType()).thenReturn("Bearer");
createClient(authClient);
streamWriter = streamClient.createWriter(TestUtils.AUTH_STREAM_NAME + TestUtils.WRITER_TEST_STREAM_NAME_POSTFIX);
try {
streamWriter.write(RestTest.EXPECTED_WRITER_CONTENT, Charsets.UTF_8).get();
} catch (ExecutionException e) {
assertEquals(HttpFailureException.class, e.getCause().getClass());
}
}
Aggregations