Search in sources :

Example 6 with IOTResponse

use of org.wso2.iot.integration.common.IOTResponse in project product-iots by wso2.

the class RoleManagement method testRemoveRole.

@Test(description = "Test remove user.", dependsOnMethods = { "testUpdateRolesOfUser" })
public void testRemoveRole() throws Exception {
    IOTResponse response = client.delete(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
Also used : IOTResponse(org.wso2.iot.integration.common.IOTResponse) Test(org.testng.annotations.Test)

Example 7 with IOTResponse

use of org.wso2.iot.integration.common.IOTResponse in project product-iots by wso2.

the class RoleManagement method testGetRoles.

@Test(description = "Test get roles.", dependsOnMethods = { "testUpdateRolePermission" })
public void testGetRoles() throws FileNotFoundException {
    IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "?offset=0&limit=2");
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
    AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_RESPONSE_PAYLOAD_FILE_NAME, Constants.UserManagement.GET_ROLES_METHOD).toString(), response.getBody(), true);
}
Also used : IOTResponse(org.wso2.iot.integration.common.IOTResponse) Test(org.testng.annotations.Test)

Example 8 with IOTResponse

use of org.wso2.iot.integration.common.IOTResponse in project product-iots by wso2.

the class RoleManagement method testGetRole.

@Test(description = "Test getting role details.", dependsOnMethods = { "testGetRolePermissions" })
public void testGetRole() throws FileNotFoundException {
    IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
    Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
Also used : IOTResponse(org.wso2.iot.integration.common.IOTResponse) Test(org.testng.annotations.Test)

Example 9 with IOTResponse

use of org.wso2.iot.integration.common.IOTResponse in project product-iots by wso2.

the class RoleManagement method testUpdateRolesOfUser.

@Test(description = "Test updating users with a given role.", dependsOnMethods = { "testGetRole" })
public void testUpdateRolesOfUser() throws FileNotFoundException, XPathExpressionException {
    boolean isRoleNameExist = false;
    IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/users", PayloadGenerator.getJsonArray(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.RoleManagement.UPDATE_ROLES_METHOD).toString());
    Assert.assertEquals("Error while updating the user list for the role administration", HttpStatus.SC_OK, response.getStatus());
    String url = Constants.UserManagement.USER_ENDPOINT + "/" + automationContext.getContextTenant().getContextUser().getUserNameWithoutDomain() + "/roles";
    response = client.get(url);
    JsonArray jsonArray = new JsonParser().parse(response.getBody()).getAsJsonObject().get("roles").getAsJsonArray();
    Assert.assertEquals("Error while retrieving the role details", HttpStatus.SC_OK, response.getStatus());
    for (JsonElement jsonElement : jsonArray) {
        if (jsonElement.getAsString().equals(ROLE_NAME)) {
            isRoleNameExist = true;
            break;
        }
    }
    if (!isRoleNameExist) {
        Assert.fail("The user is not assigned with the new role " + ROLE_NAME);
    }
}
Also used : JsonArray(com.google.gson.JsonArray) JsonElement(com.google.gson.JsonElement) IOTResponse(org.wso2.iot.integration.common.IOTResponse) JsonParser(com.google.gson.JsonParser) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)9 IOTResponse (org.wso2.iot.integration.common.IOTResponse)9 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonParser (com.google.gson.JsonParser)1