Search in sources :

Example 1 with AddAccessRequest

use of com.redhat.cloud.notifications.routers.internal.models.AddAccessRequest in project notifications-backend by RedHatInsights.

the class CrudTestHelpers method createInternalRoleAccess.

public static Optional<String> createInternalRoleAccess(Header identity, String role, String appId, int expected) {
    AddAccessRequest request = new AddAccessRequest();
    request.applicationId = UUID.fromString(appId);
    request.role = role;
    String responseBody = given().header(identity).when().contentType(JSON).body(request).post("internal/access").then().statusCode(expected).extract().asString();
    if (familyOf(expected) == SUCCESSFUL) {
        JsonObject jsonInternalRoleAccess = new JsonObject(responseBody);
        jsonInternalRoleAccess.mapTo(InternalRoleAccess.class);
        assertNotNull(jsonInternalRoleAccess.getString("id"));
        assertEquals(appId, jsonInternalRoleAccess.getString("application_id"));
        assertEquals(role, jsonInternalRoleAccess.getString("role"));
        assertNull(jsonInternalRoleAccess.getString("internal_role"));
        return Optional.of(jsonInternalRoleAccess.getString("id"));
    }
    return Optional.empty();
}
Also used : JsonObject(io.vertx.core.json.JsonObject) AddAccessRequest(com.redhat.cloud.notifications.routers.internal.models.AddAccessRequest) Matchers.containsString(org.hamcrest.Matchers.containsString)

Aggregations

AddAccessRequest (com.redhat.cloud.notifications.routers.internal.models.AddAccessRequest)1 JsonObject (io.vertx.core.json.JsonObject)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1