use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestCatalogSearchUi method testGuestCantViewUnsharedWorkspace.
@Test
public void testGuestCantViewUnsharedWorkspace() {
Map<String, Object> workspace = Collections.emptyMap();
Response res = expect(asAdmin().body(stringify(workspace)), 201).post(api());
Map body = parse(res);
String id = (String) body.get("id");
assertNotNull(id);
expect(asGuest(), 404).get(api() + "/" + id);
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestRegistry method createRegistryEntry.
private String createRegistryEntry(String id, String regId) throws Exception {
Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getCswRegistryInsert(id, regId)).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
ValidatableResponse validatableResponse = response.then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("0")));
String idPath = "//*[local-name()='identifier']/text()";
String mcardId = XmlSearch.evaluate(idPath, response.getBody().asString());
boolean foundMetacard = false;
long startTime = System.currentTimeMillis();
long metacardLookupTimeout = TimeUnit.MINUTES.toMillis(20);
while (!foundMetacard) {
LOGGER.info("Waiting for metacard to be created");
List entries = SECURITY.runAsAdminWithException(() -> {
FederationAdminService federationAdminServiceImpl = getServiceManager().getService(FederationAdminService.class);
return federationAdminServiceImpl.getRegistryMetacardsByRegistryIds(Collections.singletonList(regId));
});
if (!entries.isEmpty()) {
foundMetacard = true;
} else if (System.currentTimeMillis() - startTime > metacardLookupTimeout) {
fail("Registry Metacard was not created in the allowed time");
}
Thread.sleep(SLEEP_TIME);
}
return mcardId;
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestRegistry method testCswRegistryUpdate.
@Test
public void testCswRegistryUpdate() throws Exception {
String regID = "urn:uuid:2014ca7f59ac46f495e32b4a67a51285";
String mcardId = "2014ca7f59ac46f495e32b4a67a51285";
String id = createRegistryEntry(mcardId, regID);
Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getCswRegistryUpdate(id, "New Node Name", "2018-02-26T17:16:34.996Z", regID)).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
ValidatableResponse validatableResponse = response.then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("0")));
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestRegistry method testCswRegistryDelete.
@Test
public void testCswRegistryDelete() throws Exception {
String regID = "urn:uuid:2014ca7f59ac46f495e32b4a67a51281";
String mcardId = "2014ca7f59ac46f495e32b4a67a51281";
createRegistryEntry(mcardId, regID);
Response response = given().auth().preemptive().basic(ADMIN, ADMIN).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswRegistryDeleteRequest", ImmutableMap.of("id", mcardId))).header("Content-Type", "text/xml").expect().log().all().statusCode(200).when().post(CSW_PATH.getUrl());
ValidatableResponse validatableResponse = response.then();
validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", CoreMatchers.is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", CoreMatchers.is("1")));
}
use of com.jayway.restassured.response.Response in project ddf by codice.
the class TestFtp method verifyIngest.
private void verifyIngest(int expectedResults, String expectedTitle) {
// verify FTP PUT resulted in ingest, catalogued data
expect(String.format("Failed to verify FTP ingest expectedResult(s) of %d and expectedTitle of %s", expectedResults, expectedTitle)).within(VERIFY_INGEST_TIMEOUT_SEC, TimeUnit.SECONDS).until(() -> {
final Response response = executeOpenSearch("xml", "q=*", "count=100");
int numOfResults = response.xmlPath().getList("metacards.metacard").size();
String title = response.xmlPath().get("metacards.metacard.string.findAll { it.@name == 'title' }.value");
boolean success = numOfResults == expectedResults && title.equals(expectedTitle);
return success;
});
}
Aggregations