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());
}
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);
}
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());
}
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);
}
}
Aggregations