Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/wso2/product-emm
Browse files Browse the repository at this point in the history
  • Loading branch information
hasuniea committed Aug 26, 2016
2 parents e5fccb6 + f25f7c5 commit 30f7cb1
Show file tree
Hide file tree
Showing 25 changed files with 183 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,12 @@ public static final class RoleManagement {
public static final String ROLE_NAME = "administration";
public static final String UPDATED_ROLE_NAME = "manager";
public static final String ROLE_ENDPOINT = "/api/device-mgt/v1.0/roles";
public static final String ROLE_ENDPOINT_WITH_PAGINATION
= "/api/device-mgt/v1.0/roles?offset=0&limit=2";
public static final String SCOPE_ROLE_ENDPOINT = "/api/device-mgt/v1.0/roles/scopes";
public static final String ROLE_PAYLOAD_FILE_NAME = "role-payloads.json";
public static final String ROLE_RESPONSE_PAYLOAD
= "[{\"key\":\"role:view\",\"name\":\"View roles\",\"roles\":\"admin,manager\",\"description\":\"\"},{\"key\":\"role:manage\",\"name\":\"Add roles\",\"roles\":\"admin,manager\",\"description\":\"\"}]";
public static final String ROLE_RESPONSE_PAYLOAD_FILE_NAME = "role-response-payloads.json";
public static final String ROLE_ERRONEOUS_PAYLOAD_FILE_NAME = "role-erroneous-payloads.json";
public static final String ROLE_UPDATE_PAYLOAD_FILE_NAME = "role-update-payloads.json";
Expand All @@ -301,7 +305,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";

Expand All @@ -319,14 +323,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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testEnrollment() throws Exception {
enrollmentData.addProperty(Constants.DEVICE_IDENTIFIER_KEY, Constants.DEVICE_ID);
MDMResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT,
enrollmentData.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
Assert.assertTrue(response.getBody().contains(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FOR_POST));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public void initTest() throws Exception {
@Test(description = "Add an Android device.")
public void enrollAndroidDevice() throws Exception {
JsonObject enrollmentData = PayloadGenerator.getJsonPayload(
Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_POST);
Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST);
enrollmentData.addProperty(Constants.DEVICE_IDENTIFIER_KEY, Constants.DEVICE_ID);
MDMResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus());
Expand All @@ -59,7 +58,8 @@ public void enrollAndroidDevice() throws Exception {
Constants.HTTP_METHOD_POST).toString(), response.getBody(), true);
}

@Test(dependsOnMethods = {"enrollAndroidDevice"}, description = "Install an app to enrolled android device")
@Test(dependsOnMethods = {
"enrollAndroidDevice" }, description = "Install an app to enrolled android device")
public void testInstallApps() throws Exception {
JsonObject operationData = PayloadGenerator.getJsonPayload(
Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME,
Expand All @@ -70,7 +70,7 @@ public void testInstallApps() throws Exception {
operationData.add(Constants.DEVICE_IDENTIFIERS_KEY, deviceIds);
HttpResponse response = rclient.post(Constants.AndroidOperations.INSTALL_APPS_ENDPOINT,
operationData.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}

@Test(dependsOnMethods = {"testInstallApps"}, description = "Test get device apps with wrong Device ID")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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.")
Expand All @@ -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"})
Expand All @@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void testAddRole() throws Exception {

@Test(description = "Test view roles")
public void testViewRoles() throws Exception {
MDMResponse response = client.get(Constants.RoleManagement.ROLE_ENDPOINT);
MDMResponse response = client.get(Constants.RoleManagement.ROLE_ENDPOINT_WITH_PAGINATION);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.RoleManagement.
ROLE_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_GET).toString(),
Expand Down Expand Up @@ -82,15 +82,14 @@ public void testUpdateRoleWithErroneousPayload() throws Exception {
Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
}

@Test(description = "Test update scopes to a role.", dependsOnMethods = { "testUpdateUser"})
/*@Test(description = "Test update scopes to a role.", dependsOnMethods = { "testUpdateUser"})
public void testUpdateRolePermission() throws Exception {
String url=GetURL(Constants.RoleManagement.SCOPE_ROLE_ENDPOINT, Constants.RoleManagement.UPDATED_ROLE_NAME);
MDMResponse response = client.put(url,
PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString());
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
MDMResponse response = client.put(url, Constants.RoleManagement.ROLE_RESPONSE_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}*/

/*TODO Role detele endpoint currently expecting a payload, this has to be changed
/*@Test(description = "Test remove role.", dependsOnMethods = { "testUpdateRolePermission" })
public void testRemoveRole() throws Exception {
String url=GetURL(Constants.RoleManagement.ROLE_ENDPOINT, Constants.RoleManagement.UPDATED_ROLE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,21 @@
},
"users": [],
"roles": []
},
"PUT" : {
"compliance": "enforce",
"ownershipType": "ANY",
"profile": {
"profileName": "Camera",
"profileFeaturesList": [
{
"content": {
"enabled": true
}
}
]
},
"users": [],
"roles": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
30 changes: 15 additions & 15 deletions modules/integration/tests-integration/src/test/resources/testng.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@
<!--<class name="org.wso2.mdm.integration.user.UserManagement"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="role-mgt" preserve-order="true" parallel="false">-->
<!--<classes>-->
<!--<class name="org.wso2.mdm.integration.role.RoleManagement"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="policy-mgt" preserve-order="true" parallel="false">-->
<!--<classes>-->
<!--<class name="org.wso2.mdm.integration.policy.AndroidPolicyManagement"/>-->
<!--</classes>-->
<!--</test>-->
<test name="role-mgt" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.mdm.integration.role.RoleManagement"/>
</classes>
</test>
<test name="policy-mgt" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.mdm.integration.policy.AndroidPolicyManagement"/>
</classes>
</test>
<!--<test name="windows-policy-mgt" preserve-order="true" parallel="false">-->
<!--<classes>-->
<!--<class name="org.wso2.mdm.integration.policy.WindowsPolicyManagement"/>-->
Expand All @@ -121,11 +121,11 @@
<class name="org.wso2.mdm.integration.configuration.ConfigurationManagement"/>
</classes>
</test>
<!--<test name="notification-mgt" preserve-order="true" parallel="false">-->
<!--<classes>-->
<!--<class name="org.wso2.mdm.integration.notification.NotificationManagement"/>-->
<!--</classes>-->
<!--</test>-->
<test name="notification-mgt" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.mdm.integration.notification.NotificationManagement"/>
</classes>
</test>
<test name="certificate-mgt" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.mdm.integration.certificate.CertificateManagement"/>
Expand Down
2 changes: 1 addition & 1 deletion modules/mobile-agents/android/client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ buildscript {


dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:2.1.3'
}
}

Expand Down
Loading

0 comments on commit 30f7cb1

Please sign in to comment.