use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class RestControllerV2APIIT method testRetrieveEntityPost.
@Test
public void testRetrieveEntityPost() {
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).post(API_V2 + "V2_API_TypeTestRefAPIV2/ref1?_method=GET").then().log().all();
validateRetrieveEntityWithoutAttributeFilter(response);
}
use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class RestControllerV2APIIT method testRetrieveEntityAttributeMeta.
@Test
public void testRetrieveEntityAttributeMeta() {
ValidatableResponse response = given().log().all().header(X_MOLGENIS_TOKEN, testUserToken).get(API_V2 + "V2_API_TypeTestRefAPIV2/meta/value").then().log().all();
validateRetrieveEntityAttributeMeta(response);
}
use of io.restassured.response.ValidatableResponse in project molgenis by molgenis.
the class TwoFactorAuthenticationAPIIT method test2faEnabled.
@Test
public void test2faEnabled() {
toggle2fa(this.adminToken, TwoFactorAuthenticationSetting.ENABLED);
Gson gson = new Gson();
Map<String, String> loginBody = new HashMap<>();
loginBody.put("username", testUserName);
loginBody.put("password", TWO_FA_AUTH_TEST_USER_PASSWORD);
ValidatableResponse response = given().contentType(APPLICATION_JSON).body(gson.toJson(loginBody)).when().post(PATH + "login").then().statusCode(OKE);
testUserToken = response.extract().path("token");
}
use of io.restassured.response.ValidatableResponse in project okapi by folio-org.
the class ModuleTest method testNotFound.
@Test
public void testNotFound(TestContext context) {
async = context.async();
Response r;
ValidatableResponse then;
final String docTenantRoskilde = "{" + LS + " \"id\" : \"" + okapiTenant + "\"," + LS + " \"name\" : \"" + okapiTenant + "\"," + LS + " \"description\" : \"Roskilde bibliotek\"" + LS + "}";
r = given().header("Content-Type", "application/json").body(docTenantRoskilde).post("/_/proxy/tenants").then().statusCode(201).body(equalTo(docTenantRoskilde)).extract().response();
final String locationTenantRoskilde = r.getHeader("Location");
final String docLaunch1 = "{" + LS + " \"srvcId\" : \"sample-module-1\"," + LS + " \"nodeId\" : \"localhost\"," + LS + " \"descriptor\" : {" + LS + " \"exec\" : " + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"" + LS + " }" + LS + "}";
r = given().header("Content-Type", "application/json").body(docLaunch1).post("/_/discovery/modules").then().statusCode(201).extract().response();
locationSampleDeployment = r.getHeader("Location");
for (String type : Arrays.asList("request-response", "request-only", "headers")) {
final String docSampleModule = "{" + LS + " \"id\" : \"sample-module-1\"," + LS + " \"filters\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"path\" : \"/test2\"," + LS + " \"level\" : \"20\"," + LS + " \"type\" : \"" + type + "\"" + LS + " } ]" + LS + "}";
r = given().header("Content-Type", "application/json").body(docSampleModule).post("/_/proxy/modules").then().statusCode(201).extract().response();
final String locationSampleModule = r.getHeader("Location");
final String docEnableSample = "{" + LS + " \"id\" : \"sample-module-1\"" + LS + "}";
r = given().header("Content-Type", "application/json").body(docEnableSample).post("/_/proxy/tenants/" + okapiTenant + "/modules").then().statusCode(201).body(equalTo(docEnableSample)).extract().response();
final String enableLoc = r.getHeader("Location");
given().header("X-Okapi-Tenant", okapiTenant).body("bar").post("/test2").then().statusCode(404);
given().delete(enableLoc).then().statusCode(204);
given().delete(locationSampleModule).then().statusCode(204);
}
given().delete(locationSampleDeployment).then().statusCode(204);
locationSampleDeployment = null;
given().delete(locationTenantRoskilde).then().statusCode(204);
async.complete();
}
use of io.restassured.response.ValidatableResponse in project okapi by folio-org.
the class ModuleTest method testHeader.
@Test
public void testHeader(TestContext context) {
async = context.async();
Response r;
ValidatableResponse then;
final String docLaunch1 = "{" + LS + " \"srvcId\" : \"sample-module-5\"," + LS + " \"nodeId\" : \"localhost\"," + LS + " \"descriptor\" : {" + LS + " \"exec\" : " + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"" + LS + " }" + LS + "}";
r = given().header("Content-Type", "application/json").body(docLaunch1).post("/_/discovery/modules").then().statusCode(201).extract().response();
locationSampleDeployment = r.getHeader("Location");
final String docLaunch2 = "{" + LS + " \"srvcId\" : \"header-module-1\"," + LS + " \"nodeId\" : \"localhost\"," + LS + " \"descriptor\" : {" + LS + " \"exec\" : " + "\"java -Dport=%p -jar ../okapi-test-header-module/target/okapi-test-header-module-fat.jar\"" + LS + " }" + LS + "}";
r = given().header("Content-Type", "application/json").body(docLaunch2).post("/_/discovery/modules").then().statusCode(201).extract().response();
locationHeaderDeployment = r.getHeader("Location");
final String docSampleModule = "{" + LS + " \"id\" : \"sample-module-5\"," + LS + " \"filters\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"path\" : \"/testb\"," + LS + " \"level\" : \"20\"," + LS + " \"type\" : \"request-response\"" + LS + " } ]" + LS + "}";
r = given().header("Content-Type", "application/json").body(docSampleModule).post("/_/proxy/modules").then().statusCode(201).extract().response();
final String locationSampleModule = r.getHeader("Location");
final String docHeaderModule = "{" + LS + " \"id\" : \"header-module-1\"," + LS + " \"filters\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"path\" : \"/testb\"," + LS + " \"level\" : \"10\"," + LS + " \"type\" : \"headers\"" + LS + " } ]" + LS + "}";
r = given().header("Content-Type", "application/json").body(docHeaderModule).post("/_/proxy/modules").then().statusCode(201).extract().response();
final String locationHeaderModule = r.getHeader("Location");
final String docTenantRoskilde = "{" + LS + " \"id\" : \"" + okapiTenant + "\"," + LS + " \"name\" : \"" + okapiTenant + "\"," + LS + " \"description\" : \"Roskilde bibliotek\"" + LS + "}";
r = given().header("Content-Type", "application/json").body(docTenantRoskilde).post("/_/proxy/tenants").then().statusCode(201).body(equalTo(docTenantRoskilde)).extract().response();
final String locationTenantRoskilde = r.getHeader("Location");
final String docEnableSample = "{" + LS + " \"id\" : \"sample-module-5\"" + LS + "}";
given().header("Content-Type", "application/json").body(docEnableSample).post("/_/proxy/tenants/" + okapiTenant + "/modules").then().statusCode(201).body(equalTo(docEnableSample));
final String docEnableHeader = "{" + LS + " \"id\" : \"header-module-1\"" + LS + "}";
given().header("Content-Type", "application/json").body(docEnableHeader).post("/_/proxy/tenants/" + okapiTenant + "/modules").then().statusCode(201).body(equalTo(docEnableHeader));
given().header("X-Okapi-Tenant", okapiTenant).body("bar").post("/testb").then().statusCode(200).body(equalTo("Hello foobar")).extract().response();
given().delete("/_/proxy/tenants/" + okapiTenant + "/modules/sample-module-5").then().statusCode(204);
given().delete(locationSampleModule).then().statusCode(204);
final String docSampleModule2 = "{" + LS + " \"id\" : \"sample-module-5\"," + LS + " \"filters\" : [ {" + LS + " \"methods\" : [ \"GET\", \"POST\" ]," + LS + " \"path\" : \"/testb\"," + LS + " \"level\" : \"5\"," + LS + " \"type\" : \"request-response\"" + LS + " } ]" + LS + "}";
given().header("Content-Type", "application/json").body(docSampleModule2).post("/_/proxy/modules").then().statusCode(201).extract().response();
final String locationSampleModule2 = r.getHeader("Location");
given().header("Content-Type", "application/json").body(docEnableSample).post("/_/proxy/tenants/" + okapiTenant + "/modules").then().statusCode(201).body(equalTo(docEnableSample));
given().header("X-Okapi-Tenant", okapiTenant).body("bar").post("/testb").then().statusCode(200).body(equalTo("Hello foobar")).extract().response();
logger.debug("testHeader cleaning up");
given().delete(locationTenantRoskilde).then().statusCode(204);
given().delete(locationSampleModule).then().statusCode(204);
given().delete(locationSampleDeployment).then().statusCode(204);
locationSampleDeployment = null;
given().delete(locationHeaderDeployment).then().statusCode(204);
locationHeaderDeployment = null;
given().delete(locationHeaderModule).then().statusCode(204);
checkDbIsEmpty("testHeader done", context);
async.complete();
}
Aggregations