mirror of
https://repository.entgra.net/community/product-iots.git
synced 2025-09-16 23:32:19 +00:00
Adding test cases
This commit is contained in:
parent
3b68271159
commit
fa359b0455
@ -309,10 +309,10 @@ public final class Constants {
|
||||
public static final class UserManagement {
|
||||
public static final String USER_MANAGEMENT_GROUP = "user-mgt";
|
||||
public static final String USER_NAME = "username123";
|
||||
public static final String USER_ENDPOINT = "/mdm-admin/users";
|
||||
public static final String USER_ENDPOINT = "/api/device-mgt/v1.0/users";
|
||||
public static final String USER_PAYLOAD_FILE_NAME = "user-payloads.json";
|
||||
public static final String USER_RESPONSE_PAYLOAD_FILE_NAME = "user-response-payloads.json";
|
||||
public static final String VIEW_USER_ENDPOINT = "/mdm-admin/users/view";
|
||||
public static final String GET_ROLES_METHOD = "GET_ROLES";
|
||||
|
||||
private UserManagement() {
|
||||
throw new AssertionError();
|
||||
|
||||
@ -65,6 +65,9 @@ public class IOTServerExtension extends ExecutionListenerExtension {
|
||||
String carbonHome = serverManager.startServer("core");
|
||||
log.info(carbonHome);
|
||||
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
|
||||
|
||||
// Need to give time for the apis to be added to the synapse configurations.
|
||||
Thread.sleep(30000);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
handleException("Fail to start carbon server ", e);
|
||||
|
||||
@ -24,13 +24,18 @@ import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.automation.engine.context.TestUserMode;
|
||||
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
|
||||
import org.wso2.iot.integration.common.*;
|
||||
import org.wso2.iot.integration.common.AssertUtil;
|
||||
import org.wso2.iot.integration.common.Constants;
|
||||
import org.wso2.iot.integration.common.OAuthUtil;
|
||||
import org.wso2.iot.integration.common.PayloadGenerator;
|
||||
import org.wso2.iot.integration.common.RestClient;
|
||||
import org.wso2.iot.integration.common.TestBase;
|
||||
|
||||
/**
|
||||
* This class contains integration tests for user management backend services.
|
||||
*/
|
||||
public class UserManagement extends TestBase {
|
||||
|
||||
private String NON_EXISTING_USERNAME = "non_exiting";
|
||||
private RestClient client;
|
||||
|
||||
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
|
||||
@ -52,11 +57,11 @@ public class UserManagement extends TestBase {
|
||||
|
||||
@Test(description = "Test update user.", dependsOnMethods = {"testAddUser"})
|
||||
public void testUpdateUser() throws Exception {
|
||||
String url = GetURL(Constants.UserManagement.USER_ENDPOINT);
|
||||
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
|
||||
HttpResponse response = client.put(url,
|
||||
PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_PAYLOAD_FILE_NAME,
|
||||
Constants.HTTP_METHOD_PUT).toString());
|
||||
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
||||
Constants.HTTP_METHOD_PUT).toString(), response.getData().toString(), true);
|
||||
|
||||
@ -64,25 +69,26 @@ public class UserManagement extends TestBase {
|
||||
|
||||
@Test(description = "Test view user.", dependsOnMethods = {"testUpdateUser"})
|
||||
public void testViewUser() throws Exception {
|
||||
String url = GetURL(Constants.UserManagement.VIEW_USER_ENDPOINT);
|
||||
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
|
||||
HttpResponse response = client.get(url);
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
||||
Constants.HTTP_METHOD_GET).toString(), response.getData().toString(), true);
|
||||
}
|
||||
|
||||
@Test(description = "Test remove user.", dependsOnMethods = {"testViewUser"})
|
||||
public void testRemoveUser() throws Exception {
|
||||
String url = GetURL(Constants.UserManagement.USER_ENDPOINT);
|
||||
HttpResponse response = client.delete(url);
|
||||
@Test(description = "Test getting user roles.", dependsOnMethods = {"testViewUser"})
|
||||
public void testGetUserRoles() throws Exception {
|
||||
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME + "/roles";
|
||||
HttpResponse response = client.get(url);
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
||||
Constants.HTTP_METHOD_DELETE).toString(), response.getData().toString(), true);
|
||||
|
||||
Constants.UserManagement.GET_ROLES_METHOD).toString(), response.getData().toString(), true);
|
||||
}
|
||||
|
||||
private String GetURL(String endPoint) {
|
||||
return endPoint + "?username=" + Constants.UserManagement.USER_NAME;
|
||||
@Test(description = "Test remove user.", dependsOnMethods = {"testGetUserRoles"})
|
||||
public void testRemoveUser() throws Exception {
|
||||
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
|
||||
HttpResponse response = client.delete(url);
|
||||
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -1,24 +1,24 @@
|
||||
{
|
||||
"POST": {
|
||||
"statusCode": 201,
|
||||
"messageFromServer": "User by username: PRIMARY/username123 was successfully added."
|
||||
"username":"PRIMARY/username123",
|
||||
"firstname":"userfirstname",
|
||||
"lastname":"userlastname",
|
||||
"emailAddress":"user123@gmail.com"
|
||||
},
|
||||
"PUT": {
|
||||
"statusCode": 201,
|
||||
"messageFromServer": "User by username: username123 was successfully updated."
|
||||
"username":"username123",
|
||||
"firstname":"userfname",
|
||||
"lastname":"userlname",
|
||||
"emailAddress":"user1234@gmail.com"
|
||||
},
|
||||
"GET": {
|
||||
"statusCode": 200,
|
||||
"messageFromServer": "User information was retrieved successfully.",
|
||||
"responseContent": {
|
||||
"username": "username123",
|
||||
"firstname": "userfname",
|
||||
"lastname": "userlname",
|
||||
"emailAddress": "user1234@gmail.com"
|
||||
}
|
||||
"username": "username123",
|
||||
"firstname": "userfname",
|
||||
"lastname": "userlname",
|
||||
"emailAddress": "user1234@gmail.com"
|
||||
},
|
||||
"DELETE": {
|
||||
"statusCode": 200,
|
||||
"messageFromServer": "User by username: username123 was successfully removed."
|
||||
"GET_ROLES": {
|
||||
"roles": ["admin"],
|
||||
"count": 0
|
||||
}
|
||||
}
|
||||
@ -28,21 +28,21 @@
|
||||
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestTransformerListener"/>
|
||||
</listeners>
|
||||
|
||||
<test name="mobile-device-mgt-no-devices" preserve-order="true" parallel="false">
|
||||
<classes>
|
||||
<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagementWithNoDevices"/>
|
||||
</classes>
|
||||
</test>
|
||||
<test name="android-enrollment" preserve-order="true" parallel="false">
|
||||
<classes>
|
||||
<class name="org.wso2.iot.integration.device.enrollment.AndroidEnrollment"/>
|
||||
</classes>
|
||||
</test>
|
||||
<test name="android-operation" preserve-order="false" parallel="true">
|
||||
<classes>
|
||||
<class name="org.wso2.iot.integration.device.operation.AndroidOperation"/>
|
||||
</classes>
|
||||
</test>
|
||||
<!--<test name="mobile-device-mgt-no-devices" preserve-order="true" parallel="false">-->
|
||||
<!--<classes>-->
|
||||
<!--<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagementWithNoDevices"/>-->
|
||||
<!--</classes>-->
|
||||
<!--</test>-->
|
||||
<!--<test name="android-enrollment" preserve-order="true" parallel="false">-->
|
||||
<!--<classes>-->
|
||||
<!--<class name="org.wso2.iot.integration.device.enrollment.AndroidEnrollment"/>-->
|
||||
<!--</classes>-->
|
||||
<!--</test>-->
|
||||
<!--<test name="android-operation" preserve-order="false" parallel="true">-->
|
||||
<!--<classes>-->
|
||||
<!--<class name="org.wso2.iot.integration.device.operation.AndroidOperation"/>-->
|
||||
<!--</classes>-->
|
||||
<!--</test>-->
|
||||
<!--<test name="windows-enrollment" preserve-order="true" parallel="false">-->
|
||||
<!--<classes>-->
|
||||
<!--<class name="org.wso2.iot.integration.device.enrollment.WindowsEnrollment"/>-->
|
||||
@ -73,11 +73,11 @@
|
||||
<!--<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagement"/>-->
|
||||
<!--</classes>-->
|
||||
<!--</test>-->
|
||||
<!--<test name="user-mgt" preserve-order="true" parallel="false">-->
|
||||
<!--<classes>-->
|
||||
<!--<class name="org.wso2.iot.integration.user.UserManagement"/>-->
|
||||
<!--</classes>-->
|
||||
<!--</test>-->
|
||||
<test name="user-mgt" preserve-order="true" parallel="false">
|
||||
<classes>
|
||||
<class name="org.wso2.iot.integration.user.UserManagement"/>
|
||||
</classes>
|
||||
</test>
|
||||
<!--<test name="role-mgt" preserve-order="true" parallel="false">-->
|
||||
<!--<classes>-->
|
||||
<!--<class name="org.wso2.iot.integration.role.RoleManagement"/>-->
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user