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 #281 from madhawap/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 570cb15 + b841085 commit f25f7c5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 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 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 @@ -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
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

0 comments on commit f25f7c5

Please sign in to comment.