use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.
the class MobileQSGTestCase method testUserRoleCreation.
@Test(description = "This test case tests whether user and roles are created as expected", dependsOnMethods = { "executeQSGScript" })
public void testUserRoleCreation() throws Exception {
// Two users will be created with the quick start script, check whether those two users are created
// successfully,
String url = Constants.UserManagement.USER_ENDPOINT + "/" + username1;
HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
url = Constants.UserManagement.USER_ENDPOINT + "/" + username2;
response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
// A single role will be created with the quick start script, checking whether that role creation happens
// without problem
String rolename = "iotMobileUser";
response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + rolename);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
}
use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.
the class UserManagement method testGetUsers.
@Test(description = "Test whether the API that is used to get the users returns all the user details.", dependsOnMethods = { "testUserCount" })
public void testGetUsers() throws Exception {
int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 4 : 15;
String url = Constants.UserManagement.USER_ENDPOINT + "/?offset=0&limit=100";
HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonObject jsonElement = new JsonParser().parse(response.getData()).getAsJsonObject();
Assert.assertEquals("All the users list is not returned", expectedCount, jsonElement.get("users").getAsJsonArray().size());
}
use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.
the class UserManagement method testUserCount.
@Test(description = "Test whether correct user count is returned.", dependsOnMethods = { "testIsUserExist" })
public void testUserCount() throws Exception {
int expectedCount = this.userMode == TestUserMode.TENANT_ADMIN ? 4 : 15;
String url = Constants.UserManagement.USER_ENDPOINT + "/count";
HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonObject jsonElement = new JsonParser().parse(response.getData()).getAsJsonObject();
Assert.assertEquals("Actual user count does not match with the returned user count", expectedCount, jsonElement.get("count").getAsInt());
}
use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.
the class UserManagement method testChangePassword.
@Test(description = "Test whether the API that is used to change the password works as expected.", dependsOnMethods = { "testRemoveUser" })
public void testChangePassword() throws Exception {
String url = Constants.UserManagement.USER_ENDPOINT + "/credentials";
HttpResponse response = client.put(url, PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_PAYLOAD_FILE_NAME, Constants.UserManagement.RESET_PASSWORD_PAYLOAD).toString());
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals("Password of the user cannot be changed", "\"UserImpl password by " + "username: admin was successfully changed.\"", response.getData());
}
use of org.wso2.carbon.automation.test.utils.http.client.HttpResponse in project product-iots by wso2.
the class UserManagement method testSearchUserNames.
@Test(description = "Test whether the API that is used to get the users with particular filter returns all the " + "user details that satisfy particular filter.", dependsOnMethods = { "testGetUsers" })
public void testSearchUserNames() throws Exception {
String url = Constants.UserManagement.USER_ENDPOINT + "/search/usernames?filter=" + Constants.UserManagement.USER_NAME;
HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Relevant filtered user list in not returned correctly.", 1, jsonArray.size());
url = Constants.UserManagement.USER_ENDPOINT + "/search/usernames?filter=" + NON_EXISTING_USERNAME;
response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Relevant filtered user list in not returned correctly. Return a list of users for " + "non-existing username", 0, jsonArray.size());
}
Aggregations