use of co.cask.common.http.HttpRequest 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.common.http.HttpRequest 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.common.http.HttpRequest 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.common.http.HttpRequest 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.common.http.HttpRequest in project cdap by caskdata.
the class DatasetServiceTestBase method deployModuleBundled.
// creates a bundled jar with moduleClass and list of bundleEmbeddedJar files, moduleName and moduleClassName are
// used to make request for deploying module.
protected int deployModuleBundled(String moduleName, String moduleClassName, Class moduleClass, Location... bundleEmbeddedJars) throws IOException {
Location moduleJar = createModuleJar(moduleClass, bundleEmbeddedJars);
HttpRequest request = HttpRequest.put(getUrl("/data/modules/" + moduleName)).addHeader("X-Class-Name", moduleClassName).withBody(Locations.newInputSupplier(moduleJar)).build();
return HttpRequests.execute(request).getResponseCode();
}
Aggregations