diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/common/Constants.java b/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/common/Constants.java index ed4bf73c0..e0acd40ad 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/common/Constants.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/common/Constants.java @@ -301,7 +301,7 @@ public static final class PolicyManagement { private PolicyManagement() { throw new AssertionError();} public static final String POLICY_MANAGEMENT_GROUP = "policy-mgt"; - public static final String ADD_POLICY_ENDPOINT= "/mdm-admin/policies/active-policy"; + public static final String ADD_POLICY_ENDPOINT= "/api/device-mgt/v1.0/policies"; public static final String GET_ALL_POLICIES_ENDPOINT = "/mdm-admin/policies"; public static final String POLICY_PRIORITIES_ENDPOINT = "/mdm-admin/policies/priorities"; @@ -319,14 +319,16 @@ public static final class PolicyManagement { public static final String POLICY_RESPONSE_PAYLOAD_FILE_NAME = "policy-response-payloads.json"; public static final String POLICY_PRIORITIES_RESPONSE_PAYLOAD_FILE_NAME = "policy-priories-response-payloads.json"; - public static final String UPDATE_ANDROID_POLICY_ENDPOINT = "/mdm-admin/policies/1"; + public static final String UPDATE_ANDROID_POLICY_ENDPOINT = "/api/device-mgt/v1.0/policies/1"; public static String UPDATE_WINDOWS_POLICY_ENDPOINT = ""; + public static final String UPDATE_POLICY_RESPONSE = "\"Policy has successfully been updated.\""; - public static final String REMOVE_POLICY_ENDPOINT = "/mdm-admin/policies/bulk-remove"; + public static final String REMOVE_POLICY_ENDPOINT = "/api/device-mgt/v1.0/policies/remove-policy"; public static final String REMOVE_ANDROID_POLICY_PAYLOAD_FILE_NAME = "[1]"; public static String REMOVE_WINDOWS_POLICY_PAYLOAD_FILE_NAME = ""; + public static final String REMOVE_POLICY_RESPONSE = "\"Policies have been successfully deleted\""; - public static final String VIEW_POLICY_LIST_ENDPOINT = "/mdm-admin/policies"; + public static final String VIEW_POLICY_LIST_ENDPOINT = "/api/device-mgt/v1.0/policies"; } public static final class FeatureManagement { diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/policy/AndroidPolicyManagement.java b/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/policy/AndroidPolicyManagement.java index 3b9dece63..afc4071e5 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/policy/AndroidPolicyManagement.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/mdm/integration/policy/AndroidPolicyManagement.java @@ -44,8 +44,6 @@ public void testAddPolicy() throws Exception { PayloadGenerator.getJsonPayload(Constants.PolicyManagement.ANDROID_POLICY_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus()); - Assert.assertEquals(PayloadGenerator.getJsonPayload(Constants.PolicyManagement.POLICY_RESPONSE_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_POST).toString(),response.getBody()); } @Test(description = "Test add policy for work-profile") @@ -54,8 +52,6 @@ public void testAddWorkProfilePolicy() throws Exception{ PayloadGenerator.getJsonPayload(Constants.PolicyManagement.ANDROID_POLICY_WORK_PROFILE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus()); - Assert.assertEquals(PayloadGenerator.getJsonPayload(Constants.PolicyManagement.POLICY_RESPONSE_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_POST).toString(),response.getBody()); } @Test(description = "Test add policy with erroneous payload.") @@ -65,11 +61,11 @@ public void testAddPolicyWithErroneousPayload() throws Exception { Constants.HTTP_METHOD_POST).toString()); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); } + @Test(description = "Test view policy list.", dependsOnMethods = { "testAddPolicy"}) public void testViewPolicyList() throws Exception { MDMResponse response = client.get(Constants.PolicyManagement.VIEW_POLICY_LIST_ENDPOINT); Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); - } @Test(description = "Test update policy.", dependsOnMethods = { "testViewPolicyList"}) @@ -79,32 +75,30 @@ public void testUpdatePolicy() throws Exception { PayloadGenerator.getJsonPayload( Constants.PolicyManagement.ANDROID_POLICY_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT).toString()); - Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus()); + Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); + Assert.assertEquals(Constants.PolicyManagement.UPDATE_POLICY_RESPONSE,response.getBody()); } @Test(description = "Test update policy with erroneous payload.", dependsOnMethods = { "testAddPolicy"}) public void testUpdatePolicyWithErroneousPayload() throws Exception { MDMResponse response = client.put(Constants.PolicyManagement.UPDATE_ANDROID_POLICY_ENDPOINT, PayloadGenerator.getJsonPayload(Constants.PolicyManagement.ANDROID_POLICY_ERRONEOUS_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_POST).toString()); + Constants.HTTP_METHOD_PUT).toString()); Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); } @Test(description = "Test remove policy.", dependsOnMethods = { "testUpdatePolicy" }) public void testRemovePolicy() throws Exception { - MDMResponse response = client.post(Constants.PolicyManagement.REMOVE_POLICY_ENDPOINT, Constants.PolicyManagement.REMOVE_ANDROID_POLICY_PAYLOAD_FILE_NAME); Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); - Assert.assertEquals(PayloadGenerator.getJsonPayload(Constants.PolicyManagement.POLICY_RESPONSE_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_DELETE).toString(), response.getBody()); + Assert.assertEquals(Constants.PolicyManagement.REMOVE_POLICY_RESPONSE, response.getBody()); } @Test(description = "Test remove policy without a policies.", dependsOnMethods = { "testRemovePolicy" }) public void testRemovePolicyWithoutPolicies() throws Exception { - MDMResponse response = client.post(Constants.PolicyManagement.REMOVE_POLICY_ENDPOINT, Constants.PolicyManagement.REMOVE_ANDROID_POLICY_PAYLOAD_FILE_NAME); - Assert.assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR, response.getStatus()); + Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus()); } } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/payloads/android-policy-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/android-policy-payloads.json index e7f27dafa..2c32e8f4a 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/android-policy-payloads.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/android-policy-payloads.json @@ -4,23 +4,23 @@ "description": "Optional", "compliance": "enforce", "ownershipType": "ANY", + "active": false, "profile": { "profileName": "Camera", - "deviceType": { - "id": 1 - }, + "deviceType": "android", "profileFeaturesList": [ { "featureCode": "CAMERA", - "deviceTypeId": 1, + "deviceType": "android", "content": { - "enabled": true + "enabled": false } } ] }, - "users": [], - "roles": [] + "roles": [ + "ANY" + ] }, "PUT": { "policyName": "Camera", @@ -29,26 +29,26 @@ "ownershipType": "ANY", "profile": { "profileName": "Camera", - "deviceType": { - "id": 1 - }, + "deviceType": "android", "profileFeaturesList": [ { "featureCode": "CAMERA", - "deviceTypeId": 1, + "deviceType": "android", "content": { - "enabled": true + "enabled": false } }, { - "featureCode": "ENCRYPT_STORAGE", - "deviceTypeId": 1, + "featureCode": "DISALLOW_ADJUST_VOLUME", + "deviceType": "android", "content": { - "encrypted": true + "enabled": true } } ] }, + "users": [ + ], "roles": [ "ANY" ] diff --git a/modules/integration/tests-integration/src/test/resources/payloads/android-policy-work-profile-payload.json b/modules/integration/tests-integration/src/test/resources/payloads/android-policy-work-profile-payload.json index 9dae9dc04..f7b4eca2e 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/android-policy-work-profile-payload.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/android-policy-work-profile-payload.json @@ -1,26 +1,29 @@ -{"POST": { - "policyName": "Work-Profile", - "description": "", - "compliance": "enforce", - "ownershipType": "ANY", - "profile": { - "profileName": "Work-Profile", - "deviceType": { - "id": 1 +{ + "POST": { + "policyName":"Work-Profile", + "description":"", + "compliance":"enforce", + "ownershipType":"ANY", + "active":false, + "profile":{ + "profileName":"Work-Profile", + "deviceType":"android", + "profileFeaturesList":[ + { + "featureCode":"WORK_PROFILE", + "deviceType":"android", + "content":{ + "profileName":"Work-Profile", + "enableSystemApps":"com.google.android.apps.maps", + "hideSystemApps":"com.google.android.calculator", + "unhideSystemApps":null, + "enablePlaystoreApps":"com.google.android.whity" + } + } + ] }, - "profileFeaturesList": [{ - "featureCode": "WORK_PROFILE", - "deviceTypeId": 1, - "content": { - "DISALLOW_CROSS_PROFILE_COPY_PASTE": true, - "profileName": "WSO2 Profile", - "enableSystemApps": "com.google.android.apps.maps", - "hideSystemApps": "com.google.android.calculator", - "unhideSystemApps": null, - "enablePlaystoreApps": "com.google.android.whity" - } - }] - }, - "roles": ["ANY"] -} + "roles":[ + "ANY" + ] + } } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/payloads/policy-erroneous-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/policy-erroneous-payloads.json index 7f87a2074..a65e9a91c 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/policy-erroneous-payloads.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/policy-erroneous-payloads.json @@ -14,5 +14,21 @@ }, "users": [], "roles": [] + }, + "PUT" : { + "compliance": "enforce", + "ownershipType": "ANY", + "profile": { + "profileName": "Camera", + "profileFeaturesList": [ + { + "content": { + "enabled": true + } + } + ] + }, + "users": [], + "roles": [] } } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/payloads/policy-response-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/policy-response-payloads.json index 396a639c0..9d77f80aa 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/policy-response-payloads.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/policy-response-payloads.json @@ -4,11 +4,11 @@ "messageFromServer": "Policy has been added successfully." }, "PUT": { - "statusCode": 201, - "messageFromServer": "Policy has been updated successfully." + "statusCode": 200, + "messageFromServer": "Policy has successfully been updated." }, "DELETE": { "statusCode": 200, - "messageFromServer": "Policies have been successfully deleted." + "messageFromServer": "Policies have been successfully deleted" } }