diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java index d6bf713a..c434981a 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java @@ -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(); diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/IOTServerExtension.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/IOTServerExtension.java index a5d414d8..8c85eb48 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/IOTServerExtension.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/IOTServerExtension.java @@ -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); diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java index debc6222..080f0241 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/user/UserManagement.java @@ -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()); } - } diff --git a/modules/integration/tests-integration/src/test/resources/client/modules/addressing-1.6.1-wso2v20.mar b/modules/integration/tests-integration/src/test/resources/client/modules/addressing-1.6.1-wso2v20.mar new file mode 100644 index 00000000..d28b3a08 Binary files /dev/null and b/modules/integration/tests-integration/src/test/resources/client/modules/addressing-1.6.1-wso2v20.mar differ diff --git a/modules/integration/tests-integration/src/test/resources/payloads/user-response-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/user-response-payloads.json index 1c7279e6..7b09aa00 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/user-response-payloads.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/user-response-payloads.json @@ -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 } } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/testng.xml b/modules/integration/tests-integration/src/test/resources/testng.xml index 7e3bfa15..bec338d2 100644 --- a/modules/integration/tests-integration/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/src/test/resources/testng.xml @@ -28,21 +28,21 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -73,11 +73,11 @@ - - - - - + + + + + diff --git a/modules/integration/tests-iot-web-ui/src/test/resources/client/modules/addressing-1.6.1-wso2v20.mar b/modules/integration/tests-iot-web-ui/src/test/resources/client/modules/addressing-1.6.1-wso2v20.mar new file mode 100644 index 00000000..d28b3a08 Binary files /dev/null and b/modules/integration/tests-iot-web-ui/src/test/resources/client/modules/addressing-1.6.1-wso2v20.mar differ