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

Commit

Permalink
Merge pull request #277 from saadsahibjan/master
Browse files Browse the repository at this point in the history
Fixes for integration tests
  • Loading branch information
DilanUA authored Aug 25, 2016
2 parents b5d5e2f + ff60b36 commit 570cb15
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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 {
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 @@ -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"
}
}

0 comments on commit 570cb15

Please sign in to comment.