use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestRMWithCSRFFilter method testAllowNonBrowserInteractionWithoutHeader.
@Test
public void testAllowNonBrowserInteractionWithoutHeader() throws Exception {
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertTrue("Should have been accepted", response.getStatus() == Status.OK.getStatusCode());
assertEquals(MediaType.APPLICATION_XML_TYPE + "; " + JettyUtils.UTF_8, response.getType().toString());
String xml = response.getEntity(String.class);
verifyClusterInfoXML(xml);
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestRMWithXFSFilter method testSameOrigin.
@Test
public void testSameOrigin() throws Exception {
createInjector("SAMEORIGIN");
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertTrue("Should have received SAMEORIGIN x-frame options header", response.getHeaders().get(XFrameOptionsFilter.X_FRAME_OPTIONS).get(0).equals("SAMEORIGIN"));
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestRMWithXFSFilter method testExplicitlyDisabled.
@Test
public void testExplicitlyDisabled() throws Exception {
createInjector(null, true);
WebResource r = resource();
ClientResponse response = r.path("ws").path("v1").path("cluster").path("info").accept("application/xml").get(ClientResponse.class);
assertFalse("Should have not received x-frame options header", response.getHeaders().get(XFrameOptionsFilter.X_FRAME_OPTIONS) == null);
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestRMWebServicesReservation method testNonExistentQueueRequestListReservation.
@Test
public void testNonExistentQueueRequestListReservation() throws Exception {
rm.start();
setupCluster(100);
ReservationId id1 = getReservationIdTestHelper(1);
ReservationId id2 = getReservationIdTestHelper(2);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_1", id1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, clock.getTime(), "res_2", id2);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("queue", DEFAULT_QUEUE + "_invalid");
testListReservationHelper(resource, Status.BAD_REQUEST);
rm.stop();
}
use of com.sun.jersey.api.client.WebResource in project hadoop by apache.
the class TestRMWebServicesReservation method testInvalidEndTimeRequestListReservation.
@Test
public void testInvalidEndTimeRequestListReservation() throws Exception {
rm.start();
setupCluster(100);
long time = clock.getTime() + MINIMUM_RESOURCE_DURATION;
ReservationId id1 = getReservationIdTestHelper(1);
ReservationId id2 = getReservationIdTestHelper(2);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time, "res_1", id1);
reservationSubmissionTestHelper("reservation/submit", MediaType.APPLICATION_JSON, time + MINIMUM_RESOURCE_DURATION, "res_2", id2);
WebResource resource = constructWebResource(LIST_RESERVATION_PATH).queryParam("start-time", Long.toString((long) (time + MINIMUM_RESOURCE_DURATION * 1.3))).queryParam("end-time", "-1").queryParam("include-resource-allocations", "true").queryParam("queue", DEFAULT_QUEUE);
JSONObject json = testListReservationHelper(resource);
if (!this.isAuthenticationEnabled() && json == null) {
return;
}
JSONObject reservations = json.getJSONObject("reservations");
testRDLHelper(reservations);
String reservationName = reservations.getJSONObject("reservation-definition").getString("reservation-name");
assertEquals(reservationName, "res_2");
rm.stop();
}
Aggregations