use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method updatingMatchingTypeOfStream.
@Test
@MongoDbSeed(locations = { "single-stream", "second-single-stream" })
public void updatingMatchingTypeOfStream() {
// id of stream to be updated
final String streamId = "552b92b2e4b0c055e41ffb8d";
// id of stream that is supposed to be left untampered
final String otherStreamId = "552b92b2e4b0c055e41ffb8e";
assertThat(streamCount()).isEqualTo(2);
final JsonPath response = given().when().body("{\"matching_type\":\"OR\"}").put("/streams/" + streamId).then().statusCode(200).contentType(ContentType.JSON).extract().jsonPath();
assertThat(response.getString("matching_type")).isEqualTo("OR");
getStream(streamId).statusCode(200).assertThat().body("matching_type", equalTo("OR"));
getStream(otherStreamId).statusCode(200).assertThat().body("matching_type", equalTo("AND"));
}
use of com.jayway.restassured.path.json.JsonPath in project graylog2-server by Graylog2.
the class StreamsTest method listStreamsWhenNoStreamsArePresent.
@Test
public void listStreamsWhenNoStreamsArePresent() throws Exception {
final JsonPath response = given().when().get("/streams").then().statusCode(200).assertThat().body(".", containsAllKeys("total", "streams")).extract().jsonPath();
assertThat(response.getInt("total")).isEqualTo(0);
assertThat(response.getList("streams")).isEmpty();
}
use of com.jayway.restassured.path.json.JsonPath in project ddf by codice.
the class TestFederation method testAsyncDownloadActionPresentUsingCometDClient.
/**
* Tests that the async download action's URL is returned in the CometD search results.
*
* @throws Exception
*/
@Test
// TODO: DDF-2581
@ConditionalIgnore(condition = SkipUnstableTest.class)
public void testAsyncDownloadActionPresentUsingCometDClient() throws Exception {
getCatalogBundle().setupCaching(true);
String src = "ddf.distribution";
String metacardId = ingestXmlWithProduct(String.format("%s.txt", testName.getMethodName()));
String responseChannelId = "0193d9e7f9ed4f8f8bd02103143c41d6";
String responseChannelPath = String.format("/%s", responseChannelId);
String expectedUrl = String.format("%s?source=%s&metacard=%s", RESOURCE_DOWNLOAD_ENDPOINT_ROOT.getUrl(), src, metacardId);
String actionTitle = "Copy resource to local site";
cometDClient = setupCometDClient(Collections.singletonList(responseChannelPath));
cometDClient.searchByMetacardId(responseChannelId, src, metacardId);
expect("CometD query response").within(20, SECONDS).until(() -> cometDClient.getMessages(responseChannelPath).size() >= 1);
Optional<String> searchResult = cometDClient.searchMessages(metacardId);
assertThat("Async download action not found", searchResult.isPresent(), is(true));
JsonPath path = JsonPath.from(searchResult.get());
assertThat(path.getString(String.format(FIND_ACTION_URL_BY_TITLE_PATTERN, actionTitle)), is(expectedUrl));
}
use of com.jayway.restassured.path.json.JsonPath in project ddf by codice.
the class TestSecurity method testCertificateGeneratorService.
//Purpose is to make sure operations of the security certificate generator are accessible
//at runtime. The actual functionality of these operations is proved in unit tests.
@Test
public void testCertificateGeneratorService() throws Exception {
String commonName = "myCn";
String expectedValue = "CN=" + commonName;
String featureName = "security-certificate";
String certGenPath = SECURE_ROOT_AND_PORT + "/admin/jolokia/exec/org.codice.ddf.security.certificate.generator.CertificateGenerator:service=certgenerator";
getBackupKeystoreFile();
try {
getServiceManager().startFeature(true, featureName);
//Test first operation
Response response = given().auth().basic("admin", "admin").when().get(certGenPath + "/configureDemoCert/" + commonName);
String actualValue = JsonPath.from(response.getBody().asString()).getString("value");
assertThat(actualValue, equalTo(expectedValue));
//Test second operation
response = given().auth().basic("admin", "admin").when().get(certGenPath + "/configureDemoCertWithDefaultHostname");
String jsonString = response.getBody().asString();
JsonPath jsonPath = JsonPath.from(jsonString);
//If the key value exists, the return value is well-formatted (i.e. not a stacktrace)
assertThat(jsonPath.getString("value"), notNullValue());
//Make sure an invalid key would return null
assertThat(jsonPath.getString("someinvalidkey"), nullValue());
getServiceManager().stopFeature(false, featureName);
} finally {
restoreKeystoreFile();
}
}
use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.
the class UtilIT method getUsernameFromResponse.
static String getUsernameFromResponse(Response createUserResponse) {
JsonPath createdUser = JsonPath.from(createUserResponse.body().asString());
String username = createdUser.getString("data.user." + USERNAME_KEY);
logger.info("Username found in create user response: " + username);
return username;
}
Aggregations