Reformatting code

application-manager-new
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 String DEVICE_CONFIGURATION_GROUP = "android-config-mgt";

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

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

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

@ -55,17 +55,18 @@ public class RoleManagement extends TestBase {
@Test(description = "Test add role.")
public void testAddRole() throws FileNotFoundException {
IOTResponse response = client.post(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT,
PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_POST).toString());
IOTResponse response = client.post(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT, PayloadGenerator
.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST)
.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getStatus());
}
@Test(description = "Test update permission role.", dependsOnMethods = {"testAddRole"})
public void testUpdateRolePermission() throws FileNotFoundException {
IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME,
PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString());
PayloadGenerator
.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT)
.toString());
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"})
public void testGetFilteredRoles() throws FileNotFoundException {
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT +
"/filter/administ?offset=0&limit=2");
IOTResponse response = client
.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/filter/administ?offset=0&limit=2");
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
AssertUtil.jsonPayloadCompare(PayloadGenerator
.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"})
public void testGetRole() throws FileNotFoundException {
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT +
"/" + ROLE_NAME);
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
@Test(description = "Test updating users with a given role.", dependsOnMethods = {"testGetRole"})
public void testUpdateRolesOfUser() throws FileNotFoundException, XPathExpressionException {
IOTResponse response = client
.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/users", PayloadGenerator.getJsonArray(
Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
IOTResponse response = client.put(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/users",
PayloadGenerator.getJsonArray(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.RoleManagement.UPDATE_ROLES_METHOD).toString());
Assert.assertEquals("Error while updating the user list for the role administration", HttpStatus.SC_OK,
response.getStatus());
String url = Constants.UserManagement.USER_ENDPOINT + "/" + automationContext.getContextTenant()
.getContextUser().getUserNameWithoutDomain() + "/roles";
String url =
Constants.UserManagement.USER_ENDPOINT + "/" + automationContext.getContextTenant().getContextUser()
.getUserNameWithoutDomain() + "/roles";
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("The user is not updated with the roles list", "\"" + ROLE_NAME + "\"",
jsonArray.get(0).toString());
@ -123,7 +124,7 @@ public class RoleManagement extends TestBase {
@Test(description = "Test remove user.", dependsOnMethods = {"testUpdateRolesOfUser"})
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());
}
}

@ -101,8 +101,8 @@ public class UserManagement extends TestBase {
@Test(description = "Test the API that checks whether user exist.", dependsOnMethods = {"testGetUserRoles"})
public void testIsUserExist() throws Exception {
String url = Constants.UserManagement.USER_ENDPOINT + "/checkUser?username=" + Constants.UserManagement
.USER_NAME;
String url =
Constants.UserManagement.USER_ENDPOINT + "/checkUser?username=" + Constants.UserManagement.USER_NAME;
HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals(
@ -145,20 +145,19 @@ public class UserManagement extends TestBase {
HttpResponse response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Relevant filtered user list in not returned correctly.", 1,
jsonArray.size());
Assert.assertEquals("Relevant filtered user list in not returned correctly.", 1, jsonArray.size());
url = Constants.UserManagement.USER_ENDPOINT + "/search/usernames?filter=" + NON_EXISTING_USERNAME;
response = client.get(url);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
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"})
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);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
}

Loading…
Cancel
Save