Reformatting code

merge-requests/1/head
megala21 8 years ago
parent 23c385a7be
commit b0ab301004

@ -262,26 +262,6 @@ public final class Constants {
} }
} }
public static final class AndroidDeviceManagement {
public static final String DEVICE_MANAGEMENT_GROUP = "device-mgt";
public static final String KEY_DEVICE_ID = "deviceIdentifier";
public static final String KEY_DEVICE_NAME = "name";
public static final String DEVICE_MGT_ENDPOINT = "/api/device-mgt/android/v1.0/devices";
public static final String LICENSE_SECTION = "This";
public static final String LICENSE_ENDPOINT = DEVICE_MGT_ENDPOINT + "license";
public static final String APP_LIST_ENDPOINT = DEVICE_MGT_ENDPOINT + "appList/" +
Constants.DEVICE_ID;
public static final String REQUEST_MODIFY_DEVICE_EXPECTED = "{\"responseMessage\":\"Device information " +
"has modified successfully.\"}";
public static final String APPLIST_PAYLOAD = "{\"id\":\"1\"," +
"\"applicationIdentifier\": \"appid\",\"\"platform\": \"android\"," +
"\"name\": \"testapp\"}";
public static final String RESPONSE_PAYLOAD_FILE_NAME = "android-device-mgt-response-payloads.json";
private AndroidDeviceManagement() {
throw new AssertionError();
}
}
public static final class AndroidConfigurationManagement { public static final class AndroidConfigurationManagement {
public static final String DEVICE_CONFIGURATION_GROUP = "android-config-mgt"; public static final String DEVICE_CONFIGURATION_GROUP = "android-config-mgt";

@ -48,6 +48,13 @@ public class PayloadGenerator {
return returnString; return returnString;
} }
/**
* Create a Json Array from a specific method in the file
* @param fileName Name of the file
* @param method Method name
* @return Json Arry created from the specific method in the file
* @throws FileNotFoundException File Not found exception
*/
public static JsonArray getJsonArray(String fileName, String method) public static JsonArray getJsonArray(String fileName, String method)
throws FileNotFoundException { throws FileNotFoundException {
URL url = PayloadGenerator.class.getClassLoader().getResource(PAYLOAD_LOCATION + fileName); URL url = PayloadGenerator.class.getClassLoader().getResource(PAYLOAD_LOCATION + fileName);

@ -55,8 +55,9 @@ public class AndroidEnrollment extends TestBase {
@Test(description = "Test an Android device enrollment.") @Test(description = "Test an Android device enrollment.")
public void testEnrollment() throws Exception { public void testEnrollment() throws Exception {
String enrollmentData = PayloadGenerator.getJsonPayload(Constants.AndroidEnrollment String enrollmentData = PayloadGenerator
.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString(); .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST)
.toString();
HttpResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData); HttpResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData);
JsonParser jsonParser = new JsonParser(); JsonParser jsonParser = new JsonParser();
JsonElement element = jsonParser.parse(response.getData()); JsonElement element = jsonParser.parse(response.getData());
@ -64,72 +65,73 @@ public class AndroidEnrollment extends TestBase {
JsonElement msg = jsonObject.get("responseMessage"); JsonElement msg = jsonObject.get("responseMessage");
deviceId = msg.getAsString().split("\'")[1].split("\'")[0]; deviceId = msg.getAsString().split("\'")[1].split("\'")[0];
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( AssertUtil.jsonPayloadCompare(PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_POST).toString(), response.getData(), true); Constants.HTTP_METHOD_POST).toString(), response.getData(), true);
} }
@Test(description = "Test an Android device is enrolled.", dependsOnMethods = {"testEnrollment"}) @Test(description = "Test an Android device is enrolled.", dependsOnMethods = {"testEnrollment"})
public void testIsEnrolled() throws Exception { public void testIsEnrolled() throws Exception {
HttpResponse response = client.get(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/status"); HttpResponse response = client
.get(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/status");
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( AssertUtil.jsonPayloadCompare(PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_GET).toString(), response.getData(), true); Constants.HTTP_METHOD_GET).toString(), response.getData(), true);
} }
@Test(description = "Test modify enrollment.", dependsOnMethods = {"testIsEnrolled"}) @Test(description = "Test modify enrollment.", dependsOnMethods = {"testIsEnrolled"})
public void testModifyEnrollment() throws Exception { public void testModifyEnrollment() throws Exception {
JsonObject enrollmentData = PayloadGenerator.getJsonPayload( JsonObject enrollmentData = PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT);
Constants.HTTP_METHOD_PUT); HttpResponse response = client
HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId, .put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId, enrollmentData.toString());
enrollmentData.toString()); AssertUtil.jsonPayloadCompare(PayloadGenerator
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME,
Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT).toString(), response.getData(), true);
Constants.HTTP_METHOD_PUT).toString(), response.getData(), true);
} }
@Test(description = "Test update applications", dependsOnMethods = {"testModifyEnrollment"}) @Test(description = "Test update applications", dependsOnMethods = {"testModifyEnrollment"})
public void testUpdateApplications() throws Exception { public void testUpdateApplications() throws Exception {
JsonArray updateApplicationData = PayloadGenerator.getJsonArray( JsonArray updateApplicationData = PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, .getJsonArray(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME,
Constants.AndroidEnrollment.UPDATE_APPLICATION_METHOD); Constants.AndroidEnrollment.UPDATE_APPLICATION_METHOD);
HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + HttpResponse response = client
"/applications", updateApplicationData.toString()); .put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/applications",
Assert.assertEquals("Update of applications for the device id " + deviceId + " failed", HttpStatus updateApplicationData.toString());
.SC_ACCEPTED, response.getResponseCode()); Assert.assertEquals("Update of applications for the device id " + deviceId + " failed", HttpStatus.SC_ACCEPTED,
response = client.get(Constants.MobileDeviceManagement.CHANGE_DEVICE_STATUS_ENDPOINT + Constants response.getResponseCode());
.AndroidEnrollment.ANDROID_DEVICE_TYPE + "/" + deviceId + "/applications"); response = client.get(Constants.MobileDeviceManagement.CHANGE_DEVICE_STATUS_ENDPOINT
+ Constants.AndroidEnrollment.ANDROID_DEVICE_TYPE + "/" + deviceId + "/applications");
Assert.assertEquals("Error while getting application list for the device with the id " + deviceId + " failed", Assert.assertEquals("Error while getting application list for the device with the id " + deviceId + " failed",
HttpStatus.SC_OK, response.getResponseCode()); HttpStatus.SC_OK, response.getResponseCode());
JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray(); JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Installed applications for the device with the device id " + deviceId + " has not been " Assert.assertEquals("Installed applications for the device with the device id " + deviceId + " has not been "
+ "updated yet", 3, jsonArray.size()); + "updated yet", 3, jsonArray.size());
} }
@Test(description = "Test get pending operations", dependsOnMethods = {"testModifyEnrollment"}) @Test(description = "Test get pending operations", dependsOnMethods = {"testModifyEnrollment"})
public void testGetPendingOperations() throws Exception { public void testGetPendingOperations() throws Exception {
JsonArray pendingOperationsData = PayloadGenerator.getJsonArray( JsonArray pendingOperationsData = PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, .getJsonArray(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME,
Constants.AndroidEnrollment.GET_PENDING_OPERATIONS_METHOD); Constants.AndroidEnrollment.GET_PENDING_OPERATIONS_METHOD);
HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + HttpResponse response = client
"/pending-operations", pendingOperationsData.toString()); .put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/pending-operations",
pendingOperationsData.toString());
JsonArray pendingOperations = new JsonParser().parse(response.getData()).getAsJsonArray(); JsonArray pendingOperations = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Error while getting pending operations for android device with the id " + deviceId, Assert.assertEquals("Error while getting pending operations for android device with the id " + deviceId,
HttpStatus.SC_CREATED, response.getResponseCode()); HttpStatus.SC_CREATED, response.getResponseCode());
Assert.assertTrue("Pending operation count is 0. Periodic monitoring tasks are not running.", 0 < Assert.assertTrue("Pending operation count is 0. Periodic monitoring tasks are not running.",
pendingOperations.size()); 0 < pendingOperations.size());
} }
@Test(description = "Test disEnrollment.", dependsOnMethods = {"testGetPendingOperations"}) @Test(description = "Test disEnrollment.", dependsOnMethods = {"testGetPendingOperations"})
public void testDisEnrollDevice() throws Exception { public void testDisEnrollDevice() throws Exception {
HttpResponse response = client.delete(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId); HttpResponse response = client.delete(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( AssertUtil.jsonPayloadCompare(PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_DELETE).toString(), response.getData(), true); Constants.HTTP_METHOD_DELETE).toString(), response.getData(), true);
} }
} }

@ -50,9 +50,8 @@ public class AndroidOperation extends TestBase {
super.init(userMode); super.init(userMode);
this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
//Enroll a device //Enroll a device
JsonObject enrollmentData = PayloadGenerator.getJsonPayload( JsonObject enrollmentData = PayloadGenerator
Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST);
Constants.HTTP_METHOD_POST);
client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData.toString()); client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData.toString());
} }
@ -67,8 +66,9 @@ public class AndroidOperation extends TestBase {
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device un-lock " @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device un-lock "
+ "operation.") + "operation.")
public void testUnLock() throws MalformedURLException, AutomationFrameworkException { public void testUnLock() throws MalformedURLException, AutomationFrameworkException {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.UNLOCK_ENDPOINT, Constants.AndroidOperations.UNLOCK_OPERATION_PAYLOAD); .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.UNLOCK_ENDPOINT,
Constants.AndroidOperations.UNLOCK_OPERATION_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@ -76,41 +76,42 @@ public class AndroidOperation extends TestBase {
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device location " @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device location "
+ "operation.") + "operation.")
public void testLocation() throws Exception { public void testLocation() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.LOCATION_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.LOCATION_ENDPOINT,
Constants.AndroidOperations.LOCATION_PAYLOAD); Constants.AndroidOperations.LOCATION_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device clear password " + @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device clear password " +
"operation.") "operation.")
public void testClearPassword() throws Exception { public void testClearPassword() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
Constants.AndroidOperations.CLEAR_PASSWORD_ENDPOINT, + Constants.AndroidOperations.CLEAR_PASSWORD_ENDPOINT,
Constants.AndroidOperations.CLEAR_PASSWORD_PAYLOAD); Constants.AndroidOperations.CLEAR_PASSWORD_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device camera " @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device camera "
+ "operation.") + "operation.")
public void testCamera() throws Exception { public void testCamera() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.CAMERA_OPERATION, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.CAMERA_OPERATION,
Constants.AndroidOperations.CAMERA_OPERATION_PAYLOAD); Constants.AndroidOperations.CAMERA_OPERATION_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android get info operation") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android get info operation")
public void testGetInfo() throws Exception { public void testGetInfo() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.DEVICE_INFO_ENDPOINT, Constants.AndroidOperations.DEVICE_INFO_PAYLOAD); .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.DEVICE_INFO_ENDPOINT,
Constants.AndroidOperations.DEVICE_INFO_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android logcat operation") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android logcat operation")
public void testLogcat() throws Exception { public void testLogcat() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
Constants.AndroidOperations.DEVICE_LOGCAT_ENDPOINT, Constants.AndroidOperations.PAYLOAD_COMMON); + Constants.AndroidOperations.DEVICE_LOGCAT_ENDPOINT, Constants.AndroidOperations.PAYLOAD_COMMON);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@ -118,44 +119,47 @@ public class AndroidOperation extends TestBase {
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android enterprise-wipe " @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android enterprise-wipe "
+ "operation.") + "operation.")
public void testEnterpriseWipe() throws Exception { public void testEnterpriseWipe() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
Constants.AndroidOperations.ENTERPRISE_WIPE_ENDPOINT, + Constants.AndroidOperations.ENTERPRISE_WIPE_ENDPOINT,
Constants.AndroidOperations.ENTERPRISE_WIPE_PAYLOAD); Constants.AndroidOperations.ENTERPRISE_WIPE_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android wipe data operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android wipe data operation.")
public void testWipeData() throws Exception { public void testWipeData() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.WIPE_DATA_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.WIPE_DATA_ENDPOINT,
Constants.AndroidOperations.WIPE_DATA_PAYLOAD); Constants.AndroidOperations.WIPE_DATA_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android get applications " @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android get applications "
+ "operation.") + "operation.")
public void testGetApplications() throws Exception { public void testGetApplications() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
Constants.AndroidOperations.APPLICATION_LIST_ENDPOINT, Constants.AndroidOperations.PAYLOAD_COMMON); + Constants.AndroidOperations.APPLICATION_LIST_ENDPOINT, Constants.AndroidOperations.PAYLOAD_COMMON);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android app install operation") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android app install operation")
public void testInstallApplication() throws Exception { public void testInstallApplication() throws Exception {
JsonObject installApplicationPayload = PayloadGenerator.getJsonPayload(Constants.AndroidOperations JsonObject installApplicationPayload = PayloadGenerator
.OPERATION_PAYLOAD_FILE_NAME, Constants.AndroidOperations.INSTALL_APPS_OPERATION); .getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME,
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.INSTALL_APPS_OPERATION);
Constants.AndroidOperations.INSTALL_APPS_ENDPOINT, installApplicationPayload.toString()); HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
+ Constants.AndroidOperations.INSTALL_APPS_ENDPOINT, installApplicationPayload.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android app update operation") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android app update operation")
public void testUpdateApplication() public void testUpdateApplication()
throws FileNotFoundException, MalformedURLException, AutomationFrameworkException { throws FileNotFoundException, MalformedURLException, AutomationFrameworkException {
JsonObject installApplicationPayload = PayloadGenerator.getJsonPayload(Constants.AndroidOperations JsonObject installApplicationPayload = PayloadGenerator
.OPERATION_PAYLOAD_FILE_NAME, Constants.AndroidOperations.INSTALL_APPS_OPERATION); .getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME,
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.INSTALL_APPS_OPERATION);
Constants.AndroidOperations.UPDATE_APPS_ENDPOINT, installApplicationPayload.toString()); HttpResponse response = client
.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.UPDATE_APPS_ENDPOINT,
installApplicationPayload.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@ -172,10 +176,11 @@ public class AndroidOperation extends TestBase {
+ "operation") + "operation")
public void testBlackListApplication() public void testBlackListApplication()
throws FileNotFoundException, MalformedURLException, AutomationFrameworkException { throws FileNotFoundException, MalformedURLException, AutomationFrameworkException {
JsonObject blackListApplicationPayload = PayloadGenerator.getJsonPayload(Constants.AndroidOperations JsonObject blackListApplicationPayload = PayloadGenerator
.OPERATION_PAYLOAD_FILE_NAME, Constants.AndroidOperations.BLACKLIST_OPERATION); .getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME,
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.BLACKLIST_OPERATION);
Constants.AndroidOperations.BLACKLIST_APPS_ENDPOINT, blackListApplicationPayload.toString()); HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
+ Constants.AndroidOperations.BLACKLIST_APPS_ENDPOINT, blackListApplicationPayload.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@ -196,79 +201,80 @@ public class AndroidOperation extends TestBase {
JsonObject configureVPNPayload = PayloadGenerator JsonObject configureVPNPayload = PayloadGenerator
.getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME,
Constants.AndroidOperations.VPN_OPERATION); Constants.AndroidOperations.VPN_OPERATION);
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT HttpResponse response = client
+ Constants.AndroidOperations.VPN_ENDPOINT, configureVPNPayload.toString()); .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.VPN_ENDPOINT,
configureVPNPayload.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android reboot operation") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android reboot operation")
public void testReboot() throws Exception { public void testReboot() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.REBOOT_ENDPOINT, Constants.AndroidOperations.PAYLOAD_COMMON); .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.REBOOT_ENDPOINT,
Constants.AndroidOperations.PAYLOAD_COMMON);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android ring operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android ring operation.")
public void testRing() throws Exception { public void testRing() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.RING_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.RING_ENDPOINT,
Constants.AndroidOperations.RING_PAYLOAD); Constants.AndroidOperations.RING_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android mute operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android mute operation.")
public void testMute() throws Exception { public void testMute() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.MUTE_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.MUTE_ENDPOINT,
Constants.AndroidOperations.MUTE_PAYLOAD); Constants.AndroidOperations.MUTE_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android notification operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android notification operation.")
public void testNotification() throws Exception { public void testNotification() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
Constants.AndroidOperations.NOTIFICATION_ENDPOINT, + Constants.AndroidOperations.NOTIFICATION_ENDPOINT, Constants.AndroidOperations.NOTIFICATION_PAYLOAD);
Constants.AndroidOperations.NOTIFICATION_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android WiFi operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android WiFi operation.")
public void testWiFi() throws Exception { public void testWiFi() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.WIFI_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.WIFI_ENDPOINT,
Constants.AndroidOperations.WIFI_PAYLOAD); Constants.AndroidOperations.WIFI_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android encrypt operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android encrypt operation.")
public void testEncrypt() throws Exception { public void testEncrypt() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.ENCRYPT_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.ENCRYPT_ENDPOINT,
Constants.AndroidOperations.ENCRYPT_PAYLOAD); Constants.AndroidOperations.ENCRYPT_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android change lock operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android change lock operation.")
public void testChangeLock() throws Exception { public void testChangeLock() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.CHANGE_LOCK_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.CHANGE_LOCK_ENDPOINT,
Constants.AndroidOperations.CHANGE_LOCK_PAYLOAD); Constants.AndroidOperations.CHANGE_LOCK_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android password policy operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android password policy operation.")
public void testPasswordPolicy() throws Exception { public void testPasswordPolicy() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
Constants.AndroidOperations.PASSWORD_POLICY_ENDPOINT, + Constants.AndroidOperations.PASSWORD_POLICY_ENDPOINT,
Constants.AndroidOperations.PASSWORD_POLICY_PAYLOAD); Constants.AndroidOperations.PASSWORD_POLICY_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android web clip operation.") @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android web clip operation.")
public void testWebClip() throws Exception { public void testWebClip() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT + HttpResponse response = client
Constants.AndroidOperations.WEB_CLIP_ENDPOINT, .post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.WEB_CLIP_ENDPOINT,
Constants.AndroidOperations.WEB_CLIP_PAYLOAD); Constants.AndroidOperations.WEB_CLIP_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
} }
} }

@ -82,7 +82,4 @@ public class MobileDeviceManagementWithNoDevices extends TestBase {
String tokenString = OAuthUtil.getScopes(backendHTTPSURL, backendHTTPSURL); String tokenString = OAuthUtil.getScopes(backendHTTPSURL, backendHTTPSURL);
return tokenString.contains(permissionsList); return tokenString.contains(permissionsList);
} }
} }

@ -55,17 +55,18 @@ public class RoleManagement extends TestBase {
@Test(description = "Test add role.") @Test(description = "Test add role.")
public void testAddRole() throws FileNotFoundException { public void testAddRole() throws FileNotFoundException {
IOTResponse response = client.post(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT, IOTResponse response = client.post(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT, PayloadGenerator
PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST)
Constants.HTTP_METHOD_POST).toString()); .toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus()); Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus());
} }
@Test(description = "Test update permission role.", dependsOnMethods = {"testAddRole"}) @Test(description = "Test update permission role.", dependsOnMethods = {"testAddRole"})
public void testUpdateRolePermission() throws FileNotFoundException { public void testUpdateRolePermission() throws FileNotFoundException {
IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME, IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME,
PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, PayloadGenerator
Constants.HTTP_METHOD_PUT).toString()); .getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT)
.toString());
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
} }
@ -80,8 +81,8 @@ public class RoleManagement extends TestBase {
@Test(description = "Test getting roles that has particular prefix.", dependsOnMethods = {"testGetRoles"}) @Test(description = "Test getting roles that has particular prefix.", dependsOnMethods = {"testGetRoles"})
public void testGetFilteredRoles() throws FileNotFoundException { public void testGetFilteredRoles() throws FileNotFoundException {
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + IOTResponse response = client
"/filter/administ?offset=0&limit=2"); .get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/filter/administ?offset=0&limit=2");
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
AssertUtil.jsonPayloadCompare(PayloadGenerator AssertUtil.jsonPayloadCompare(PayloadGenerator
.getJsonPayload(Constants.RoleManagement.ROLE_RESPONSE_PAYLOAD_FILE_NAME, .getJsonPayload(Constants.RoleManagement.ROLE_RESPONSE_PAYLOAD_FILE_NAME,
@ -97,25 +98,25 @@ public class RoleManagement extends TestBase {
@Test(description = "Test getting role details.", dependsOnMethods = {"testGetRolePermissions"}) @Test(description = "Test getting role details.", dependsOnMethods = {"testGetRolePermissions"})
public void testGetRole() throws FileNotFoundException { public void testGetRole() throws FileNotFoundException {
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
"/" + ROLE_NAME);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
} }
@Test(description = "Test updating users with a given role.", dependsOnMethods = {"testGetRole"}) @Test(description = "Test updating users with a given role.", dependsOnMethods = {"testGetRole"})
public void testUpdateRolesOfUser() throws FileNotFoundException, XPathExpressionException { public void testUpdateRolesOfUser() throws FileNotFoundException, XPathExpressionException {
IOTResponse response = client IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/users",
.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/users", PayloadGenerator.getJsonArray( PayloadGenerator.getJsonArray(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.RoleManagement.UPDATE_ROLES_METHOD).toString()); Constants.RoleManagement.UPDATE_ROLES_METHOD).toString());
Assert.assertEquals("Error while updating the user list for the role administration", HttpStatus.SC_OK, Assert.assertEquals("Error while updating the user list for the role administration", HttpStatus.SC_OK,
response.getStatus()); response.getStatus());
String url = Constants.UserManagement.USER_ENDPOINT + "/" + automationContext.getContextTenant() String url =
.getContextUser().getUserNameWithoutDomain() + "/roles"; Constants.UserManagement.USER_ENDPOINT + "/" + automationContext.getContextTenant().getContextUser()
.getUserNameWithoutDomain() + "/roles";
response = client.get(url); response = client.get(url);
JsonArray jsonArray = new JsonParser().parse(response.getBody()).getAsJsonObject().get("roles").getAsJsonArray(); JsonArray jsonArray = new JsonParser().parse(response.getBody()).getAsJsonObject().get("roles")
.getAsJsonArray();
Assert.assertEquals("Error while retrieving the role details", HttpStatus.SC_OK, response.getStatus()); Assert.assertEquals("Error while retrieving the role details", HttpStatus.SC_OK, response.getStatus());
Assert.assertEquals("The user is not updated with the roles list", "\"" + ROLE_NAME + "\"", Assert.assertEquals("The user is not updated with the roles list", "\"" + ROLE_NAME + "\"",
jsonArray.get(0).toString()); jsonArray.get(0).toString());
@ -123,7 +124,7 @@ public class RoleManagement extends TestBase {
@Test(description = "Test remove user.", dependsOnMethods = {"testUpdateRolesOfUser"}) @Test(description = "Test remove user.", dependsOnMethods = {"testUpdateRolesOfUser"})
public void testRemoveRole() throws Exception { public void testRemoveRole() throws Exception {
IOTResponse response = client.delete(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT +"/" + ROLE_NAME); IOTResponse response = client.delete(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
} }
} }

@ -101,8 +101,8 @@ public class UserManagement extends TestBase {
@Test(description = "Test the API that checks whether user exist.", dependsOnMethods = {"testGetUserRoles"}) @Test(description = "Test the API that checks whether user exist.", dependsOnMethods = {"testGetUserRoles"})
public void testIsUserExist() throws Exception { public void testIsUserExist() throws Exception {
String url = Constants.UserManagement.USER_ENDPOINT + "/checkUser?username=" + Constants.UserManagement String url =
.USER_NAME; Constants.UserManagement.USER_ENDPOINT + "/checkUser?username=" + Constants.UserManagement.USER_NAME;
HttpResponse response = client.get(url); HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals( Assert.assertEquals(
@ -145,20 +145,19 @@ public class UserManagement extends TestBase {
HttpResponse response = client.get(url); HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray(); JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Relevant filtered user list in not returned correctly.", 1, Assert.assertEquals("Relevant filtered user list in not returned correctly.", 1, jsonArray.size());
jsonArray.size());
url = Constants.UserManagement.USER_ENDPOINT + "/search/usernames?filter=" + NON_EXISTING_USERNAME; url = Constants.UserManagement.USER_ENDPOINT + "/search/usernames?filter=" + NON_EXISTING_USERNAME;
response = client.get(url); response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray(); jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Relevant filtered user list in not returned correctly. Return a list of users for " Assert.assertEquals("Relevant filtered user list in not returned correctly. Return a list of users for "
+ "non-existing username", 0, jsonArray.size()); + "non-existing username", 0, jsonArray.size());
} }
@Test(description = "Test remove user.", dependsOnMethods = {"testSearchUserNames"}) @Test(description = "Test remove user.", dependsOnMethods = {"testSearchUserNames"})
public void testRemoveUser() throws Exception { public void testRemoveUser() throws Exception {
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME ; String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
HttpResponse response = client.delete(url); HttpResponse response = client.delete(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
} }

Loading…
Cancel
Save