Merge pull request #366 from Megala21/test_case_fixes

Improving android test cases
application-manager-new
sinthuja 8 years ago committed by GitHub
commit b02f4c9c27

@ -58,7 +58,8 @@ public final class Constants {
public static final String API_APP_REGISTRATION_ENDPOINT = "/api-application-registration/register";
public static final String TOKEN_ENDPOINT = "/token";
public static final String MULTI_TENANT_OAUTH_TOKEN_PAYLOAD = "&grant_type=password&scope=perm:android:enroll"
+ " perm:android:wipe perm:android:ring perm:android:lock-devices perm:android:configure-vpn perm:android:configure-wifi perm:android:enroll perm:android:uninstall-application perm:android:manage-configuration perm:android:location perm:android:install-application perm:android:mute perm:android:change-lock-code perm:android:blacklist-applications perm:android:set-password-policy perm:android:encrypt-storage perm:android:clear-password perm:android:enterprise-wipe perm:android:info perm:android:view-configuration perm:android:upgrade-firmware perm:android:set-webclip perm:android:send-notification perm:android:disenroll perm:android:update-application perm:android:unlock-devices perm:android:control-camera perm:android:reboot perm:android:logcat appm:subscribe perm:sign-csr perm:admin:devices:view perm:roles:add perm:roles:add-users perm:roles:update perm:roles:permissions perm:roles:details perm:roles:view perm:roles:create-combined-role perm:roles:delete perm:dashboard:vulnerabilities perm:dashboard:non-compliant-count perm:dashboard:non-compliant perm:dashboard:by-groups perm:dashboard:device-counts perm:dashboard:feature-non-compliant perm:dashboard:count-overview perm:dashboard:filtered-count perm:dashboard:details perm:get-activity perm:devices:delete perm:devices:applications perm:devices:effective-policy perm:devices:compliance-data perm:devices:features perm:devices:operations perm:devices:search perm:devices:details perm:devices:update perm:devices:view perm:view-configuration perm:manage-configuration perm:policies:remove perm:policies:priorities perm:policies:deactivate perm:policies:get-policy-details perm:policies:manage perm:policies:activate perm:policies:update perm:policies:changes perm:policies:get-details perm:users:add perm:users:details perm:users:count perm:users:delete perm:users:roles perm:users:user-details perm:users:credentials perm:users:search perm:users:is-exist perm:users:update perm:users:send-invitation perm:admin-users:view perm:groups:devices perm:groups:update perm:groups:add perm:groups:device perm:groups:devices-count perm:groups:remove perm:groups:groups perm:groups:groups-view perm:groups:share perm:groups:count perm:groups:roles perm:groups:devices-remove perm:groups:devices-add perm:groups:assign perm:device-types:features perm:device-types:types perm:applications:install perm:applications:uninstall perm:admin-groups:count perm:admin-groups:view perm:notifications:mark-checked perm:notifications:view perm:admin:certificates:delete perm:admin:certificates:details perm:admin:certificates:view perm:admin:certificates:add perm:admin:certificates:verify perm:ios:enroll perm:ios:view-device perm:ios:apn perm:ios:ldap perm:ios:enterprise-app perm:ios:store-application perm:ios:remove-application perm:ios:app-list perm:ios:profile-list perm:ios:lock perm:ios:enterprise-wipe perm:ios:device-info perm:ios:restriction perm:ios:email perm:ios:cellular perm:ios:applications perm:ios:wifi perm:ios:ring perm:ios:location perm:ios:notification perm:ios:airplay perm:ios:caldav perm:ios:cal-subscription perm:ios:passcode-policy perm:ios:webclip perm:ios:vpn perm:ios:per-app-vpn perm:ios:app-to-per-app-vpn perm:ios:app-lock perm:ios:clear-passcode perm:ios:remove-profile perm:ios:get-restrictions perm:ios:wipe-data perm:admin";
+ " perm:android:wipe perm:android:ring perm:android:lock-devices perm:android:configure-vpn "
+ "perm:android:configure-wifi perm:android:enroll perm:android:uninstall-application perm:android:manage-configuration perm:android:location perm:android:install-application perm:android:mute perm:android:change-lock-code perm:android:blacklist-applications perm:android:set-password-policy perm:android:encrypt-storage perm:android:clear-password perm:android:enterprise-wipe perm:android:info perm:android:view-configuration perm:android:upgrade-firmware perm:android:set-webclip perm:android:send-notification perm:android:disenroll perm:android:update-application perm:android:unlock-devices perm:android:control-camera perm:android:reboot perm:android:logcat appm:subscribe perm:sign-csr perm:admin:devices:view perm:roles:add perm:roles:add-users perm:roles:update perm:roles:permissions perm:roles:details perm:roles:view perm:roles:create-combined-role perm:roles:delete perm:dashboard:vulnerabilities perm:dashboard:non-compliant-count perm:dashboard:non-compliant perm:dashboard:by-groups perm:dashboard:device-counts perm:dashboard:feature-non-compliant perm:dashboard:count-overview perm:dashboard:filtered-count perm:dashboard:details perm:get-activity perm:devices:delete perm:devices:applications perm:devices:effective-policy perm:devices:compliance-data perm:devices:features perm:devices:operations perm:devices:search perm:devices:details perm:devices:update perm:devices:view perm:view-configuration perm:manage-configuration perm:policies:remove perm:policies:priorities perm:policies:deactivate perm:policies:get-policy-details perm:policies:manage perm:policies:activate perm:policies:update perm:policies:changes perm:policies:get-details perm:users:add perm:users:details perm:users:count perm:users:delete perm:users:roles perm:users:user-details perm:users:credentials perm:users:search perm:users:is-exist perm:users:update perm:users:send-invitation perm:admin-users:view perm:groups:devices perm:groups:update perm:groups:add perm:groups:device perm:groups:devices-count perm:groups:remove perm:groups:groups perm:groups:groups-view perm:groups:share perm:groups:count perm:groups:roles perm:groups:devices-remove perm:groups:devices-add perm:groups:assign perm:device-types:features perm:device-types:types perm:applications:install perm:applications:uninstall perm:admin-groups:count perm:admin-groups:view perm:notifications:mark-checked perm:notifications:view perm:admin:certificates:delete perm:admin:certificates:details perm:admin:certificates:view perm:admin:certificates:add perm:admin:certificates:verify perm:ios:enroll perm:ios:view-device perm:ios:apn perm:ios:ldap perm:ios:enterprise-app perm:ios:store-application perm:ios:remove-application perm:ios:app-list perm:ios:profile-list perm:ios:lock perm:ios:enterprise-wipe perm:ios:device-info perm:ios:restriction perm:ios:email perm:ios:cellular perm:ios:applications perm:ios:wifi perm:ios:ring perm:ios:location perm:ios:notification perm:ios:airplay perm:ios:caldav perm:ios:cal-subscription perm:ios:passcode-policy perm:ios:webclip perm:ios:vpn perm:ios:per-app-vpn perm:ios:app-to-per-app-vpn perm:ios:app-lock perm:ios:clear-passcode perm:ios:remove-profile perm:ios:get-restrictions perm:ios:wipe-data perm:admin perm:android:applications";
public static final String OAUTH_TOKEN_PAYLOAD = "username=admin&password=admin" +
MULTI_TENANT_OAUTH_TOKEN_PAYLOAD;
@ -67,32 +68,32 @@ public final class Constants {
+ " \"applicationName\":\"app_123456\",\n" + " \"isAllowedToAllDomains\":false,\n"
+ " \"tags\":[\"android\", \"device_management\"],\n" + " \"isMappingAnExistingOAuthApp\":false\n"
+ "}").toString();
public static final String PERMISSION_LIST = "default perm:admin-groups:count perm:admin-groups:view " +
"perm:admin-users:view perm:admin:certificates:add perm:admin:certificates:delete " +
"perm:admin:certificates:details perm:admin:certificates:verify perm:admin:certificates:view " +
"perm:admin:devices:view perm:android:blacklist-applications perm:android:change-lock-code " +
"perm:android:clear-password perm:android:configure-vpn perm:android:configure-wifi " +
"perm:android:control-camera perm:android:disenroll perm:android:encrypt-storage " +
"perm:android:enroll perm:android:enterprise-wipe perm:android:info perm:android:install-application " +
"perm:android:location perm:android:lock-devices perm:android:logcat perm:android:manage-configuration " +
"perm:android:mute perm:android:reboot perm:android:ring perm:android:send-notification " +
"perm:android:set-password-policy perm:android:set-webclip perm:android:uninstall-application " +
"perm:android:unlock-devices perm:android:update-application perm:android:upgrade-firmware " +
"perm:android:view-configuration perm:android:wipe perm:applications:install perm:applications:uninstall " +
"perm:device-types:features perm:device-types:types perm:devices:applications " +
"perm:devices:compliance-data perm:devices:delete perm:devices:details perm:devices:effective-policy " +
"perm:devices:features perm:devices:operations perm:devices:search perm:devices:update " +
"perm:devices:view perm:get-activity perm:groups:add perm:groups:assign perm:groups:count " +
"perm:groups:device perm:groups:devices perm:groups:devices-add perm:groups:devices-count " +
"perm:groups:devices-remove perm:groups:groups perm:groups:groups-view perm:groups:remove " +
"perm:groups:roles perm:groups:share perm:groups:update perm:manage-configuration " +
"perm:notifications:mark-checked perm:notifications:view perm:policies:activate " +
"perm:policies:changes perm:policies:deactivate perm:policies:get-details perm:policies:get-policy-details " +
"perm:policies:manage perm:policies:priorities perm:policies:remove perm:policies:update perm:roles:add" +
" perm:roles:add-users perm:roles:create-combined-role perm:roles:delete perm:roles:details " +
"perm:roles:permissions perm:roles:update perm:roles:view perm:users:add perm:users:count " +
"perm:users:credentials perm:users:delete perm:users:details perm:users:is-exist perm:users:roles " +
"perm:users:search perm:users:send-invitation perm:users:update perm:users:user-details perm:view-configuration";
public static final String PERMISSION_LIST = "default perm:admin-groups:count perm:admin-groups:view "
+ "perm:admin-users:view perm:admin:certificates:add perm:admin:certificates:delete "
+ "perm:admin:certificates:details perm:admin:certificates:verify perm:admin:certificates:view "
+ "perm:admin:devices:view perm:android:applications perm:android:blacklist-applications "
+ "perm:android:change-lock-code perm:android:clear-password perm:android:configure-vpn perm:android:configure-wifi "
+ "perm:android:control-camera perm:android:disenroll perm:android:encrypt-storage "
+ "perm:android:enroll perm:android:enterprise-wipe perm:android:info perm:android:install-application "
+ "perm:android:location perm:android:lock-devices perm:android:logcat perm:android:manage-configuration "
+ "perm:android:mute perm:android:reboot perm:android:ring perm:android:send-notification "
+ "perm:android:set-password-policy perm:android:set-webclip perm:android:uninstall-application "
+ "perm:android:unlock-devices perm:android:update-application perm:android:upgrade-firmware "
+ "perm:android:view-configuration perm:android:wipe perm:applications:install perm:applications:uninstall "
+ "perm:device-types:features perm:device-types:types perm:devices:applications "
+ "perm:devices:compliance-data perm:devices:delete perm:devices:details perm:devices:effective-policy "
+ "perm:devices:features perm:devices:operations perm:devices:search perm:devices:update "
+ "perm:devices:view perm:get-activity perm:groups:add perm:groups:assign perm:groups:count "
+ "perm:groups:device perm:groups:devices perm:groups:devices-add perm:groups:devices-count "
+ "perm:groups:devices-remove perm:groups:groups perm:groups:groups-view perm:groups:remove "
+ "perm:groups:roles perm:groups:share perm:groups:update perm:manage-configuration "
+ "perm:notifications:mark-checked perm:notifications:view perm:policies:activate "
+ "perm:policies:changes perm:policies:deactivate perm:policies:get-details perm:policies:get-policy-details "
+ "perm:policies:manage perm:policies:priorities perm:policies:remove perm:policies:update perm:roles:add"
+ " perm:roles:add-users perm:roles:create-combined-role perm:roles:delete perm:roles:details "
+ "perm:roles:permissions perm:roles:update perm:roles:view perm:users:add perm:users:count "
+ "perm:users:credentials perm:users:delete perm:users:details perm:users:is-exist perm:users:roles "
+ "perm:users:search perm:users:send-invitation perm:users:update perm:users:user-details perm:view-configuration";
private APIApplicationRegistration() {
throw new AssertionError();
@ -104,7 +105,9 @@ public final class Constants {
public static final String ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME = "android-enrollment-response-payloads.json";
public static final String ENROLLMENT_ENDPOINT = "/api/device-mgt/android/v1.0/devices";
public static final String ENROLLMENT_GROUP = "android-enrollment";
public static final String UPDATE_APPLICATION_METHOD = "UPDATE_APPLICATIONS";
public static final String ANDROID_DEVICE_TYPE = "android";
public static final String GET_PENDING_OPERATIONS_METHOD = "GET_PENDING_OPERATIONS";
private AndroidEnrollment() {
throw new AssertionError();
}
@ -145,7 +148,7 @@ public final class Constants {
}
public static final class AndroidOperations {
private static final String PAYLOAD_COMMON = "[" + DEVICE_ID + "]";
public static final String PAYLOAD_COMMON = "[" + DEVICE_ID + "]";
public static final String OPERATION_PAYLOAD_FILE_NAME = "android-operation-payloads.json";
public static final String OPERATIONS_GROUP = "operations";
@ -179,9 +182,11 @@ public final class Constants {
public static final String CLEAR_PASSWORD_ENDPOINT = "clear-password";
public static final String CLEAR_PASSWORD_PAYLOAD = PAYLOAD_COMMON;
public static final String DEVICE_INFO_ENDPOINT = "/info";
public static final String DEVICE_INFO_ENDPOINT = "info";
public static final String DEVICE_INFO_PAYLOAD = "[\"" + DEVICE_ID + "\"]";
public static final String DEVICE_LOGCAT_ENDPOINT = "logcat";
public static final String ENTERPRISE_WIPE_ENDPOINT = "enterprise-wipe";
public static final String ENTERPRISE_WIPE_PAYLOAD = PAYLOAD_COMMON;
@ -199,6 +204,7 @@ public final class Constants {
public static final String MUTE_PAYLOAD = PAYLOAD_COMMON;
public static final String INSTALL_APPS_ENDPOINT = "install-application";
public static final String UPDATE_APPS_ENDPOINT = "update-application";
public static final String INSTALL_APPS_PAYLOAD = "{\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n"
+ " ],\n" + " \"operation\": {\n" + " \"appIdentifier\": \"string\",\n"
+ " \"type\": \"string\",\n" + " \"url\": \"string\"\n" + " }\n" + "}";
@ -206,10 +212,16 @@ public final class Constants {
public static final String UNINSTALL_APPS_ENDPOINT = "uninstall-application";
public static final String UNINSTALL_APPS_PAYLOAD = "{\n" + " \"deviceIDs\": [\n"
+ " \"" + DEVICE_ID + "\"\n" + " ],\n" + " \"operation\": {\n"
+ " \"appIdentifier\": \"string\",\n" + " \"type\": \"string\",\n" + " \"url\": \"string\",\n"
+ " \"name\": \"string\"\n" + " }\n" + "}";
+ " \"appIdentifier\": \"string\",\n" + " \"type\": \"enterprise\"} }";
public static final String BLACKLIST_APPS_ENDPOINT = "blacklist-applications";
public static final String BLACKLIST_OPERATION = "black_list_application";
public static final String UPGRADE_FIRMWARE_ENDPOINT = "upgrade-firmware";
public static final String UPGRADE_FIRMWARE_OPERATION = "upgrade-firmware";
public static final String VPN_ENDPOINT = "configure-vpn";
public static final String VPN_OPERATION = "vpn";
public static final String NOTIFICATION_ENDPOINT = "send-notification";
public static final String NOTIFICATION_PAYLOAD = "{\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n"
@ -250,30 +262,11 @@ 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 = "/mdm-android-agent/device/";
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";
public static final String CONFIG_MGT_ENDPOINT = "/mdm-android-agent/configuration/";
public static final String CONFIG_MGT_ENDPOINT = "/api/device-mgt/android/v1.0/configuration/";
public static final String LICENSE_ENDPOINT = "license";
public static final String PAYLOAD_FILE_NAME = "android-configuration-payloads.json";
public static final String RESPONSE_PAYLOAD_FILE_NAME = "android-config-response-payloads.json";
@ -330,6 +323,7 @@ public final class Constants {
public static final String ROLE_PAYLOAD_FILE_NAME = "role-payloads.json";
public static final String ROLE_RESPONSE_PAYLOAD_FILE_NAME = "role-response-payloads.json";
public static final String GET_FILTERED_ROLED_METHOD = "GET_FILTERED_ROLES";
public static final String UPDATE_ROLES_METHOD = "UPDATE_USERS";
private RoleManagement() {
throw new AssertionError();
}

@ -18,6 +18,7 @@
package org.wso2.iot.integration.common;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.io.IOUtils;
@ -46,4 +47,18 @@ public class PayloadGenerator {
String returnString = IOUtils.toString(fisTargetFile, Constants.UTF8);
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);
JsonObject jsonObject = parser.parse(new FileReader(url.getPath())).getAsJsonObject();
return jsonObject.get(method).getAsJsonArray();
}
}

@ -17,8 +17,11 @@
*/
package org.wso2.iot.integration.common;
import org.apache.commons.net.util.Base64;
import org.testng.annotations.DataProvider;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.context.beans.User;
import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil;
import org.wso2.carbon.integration.common.utils.LoginLogoutClient;
@ -31,6 +34,8 @@ public class TestBase {
protected AutomationContext automationContext;
protected String backendHTTPSURL;
protected String backendHTTPURL;
protected String accessTokenString;
protected TestUserMode userMode;
protected void init(TestUserMode userMode) throws Exception {
automationContext = new AutomationContext(Constants.AUTOMATION_CONTEXT, userMode);
@ -39,6 +44,13 @@ public class TestBase {
.HTTPS_GATEWAY_PORT)).replace("/t/" + tenantDomain , "");
backendHTTPURL = automationContext.getContextUrls().getWebAppURL().replace("9763", String.valueOf(Constants
.HTTP_GATEWAY_PORT)).replace("/t/" + tenantDomain , "");
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64
.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
accessTokenString = "Bearer " + OAuthUtil
.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(),
currentUser.getPassword());
}
protected void initPublisher(String productGroupName, String instanceName,
@ -76,4 +88,12 @@ public class TestBase {
protected String getTestArtifactLocation() {
return FrameworkPathUtil.getSystemResourceLocation();
}
@DataProvider
public static Object[][] userModeProvider() {
return new TestUserMode[][]{
new TestUserMode[]{TestUserMode.SUPER_TENANT_ADMIN},
new TestUserMode[]{TestUserMode.TENANT_ADMIN}
};
}
}

@ -20,9 +20,13 @@ package org.wso2.iot.integration.device.configuration;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.net.util.Base64;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.context.beans.User;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.iot.integration.common.*;
@ -30,55 +34,45 @@ import org.wso2.iot.integration.common.*;
* This class contains integration tests for Android configuration management backend services.
*/
public class AndroidConfigurationManagement extends TestBase {
private RestClient client;
@BeforeClass(alwaysRun = true, groups = { Constants.AndroidConfigurationManagement.DEVICE_CONFIGURATION_GROUP})
public void initTest() throws Exception {
super.init(TestUserMode.SUPER_TENANT_ADMIN);
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPURL, backendHTTPSURL);
this.client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON, accessTokenString);
@Factory(dataProvider = "userModeProvider")
public AndroidConfigurationManagement(TestUserMode testUserMode) {
this.userMode = testUserMode;
}
@Test(description = "Test add android platform configuration.")
public void testAddConfiguration() throws Exception {
HttpResponse response = client.post(Constants.AndroidConfigurationManagement.CONFIG_MGT_ENDPOINT,
PayloadGenerator.getJsonPayload(
Constants.AndroidConfigurationManagement.PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_POST).toString()
);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(
Constants.AndroidConfigurationManagement.RESPONSE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_POST).toString(),
response.getData().toString(), true
);
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(userMode);
this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
}
@Test(description = "Test update android configuration.", dependsOnMethods = {"testAddConfiguration"})
@Test(description = "Test update android configuration.")
public void testModifyConfiguration() throws Exception {
HttpResponse response = client.put(Constants.AndroidConfigurationManagement.CONFIG_MGT_ENDPOINT,
PayloadGenerator.getJsonPayload(
Constants.AndroidConfigurationManagement.PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString()
);
PayloadGenerator.getJsonPayload(Constants.AndroidConfigurationManagement.PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString());
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(
Constants.AndroidConfigurationManagement.RESPONSE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString(),
response.getData().toString(), true
);
Assert.assertEquals("Android configuration update message is not received properly",
"Android platform " + "configuration has been updated successfully.",
response.getData().replaceAll("\"", ""));
}
// @Test(description = "Test get android configuration.",
// dependsOnMethods = { "testAddConfiguration", "testModifyConfiguration" })
// public void testGetConfiguration() throws Exception {
// HttpResponse response = client.get(Constants.AndroidConfigurationManagement.CONFIG_MGT_ENDPOINT);
// Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
// AssertUtil.jsonPayloadCompare(
// PayloadGenerator.getJsonPayload(Constants.AndroidConfigurationManagement.PAYLOAD_FILE_NAME,
// Constants.HTTP_METHOD_PUT).toString(),
// response.getData().toString(), true
// );
// }
@Test(description = "Test get android configuration.", dependsOnMethods = { "testModifyConfiguration" })
public void testGetConfiguration() throws Exception {
HttpResponse response = client.get(Constants.AndroidConfigurationManagement.CONFIG_MGT_ENDPOINT);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator
.getJsonPayload(Constants.AndroidConfigurationManagement.PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_PUT)
.toString(), response.getData(), true);
}
@Test(description = "Test get android license.", dependsOnMethods = { "testModifyConfiguration" })
public void testGetLicense() throws Exception {
HttpResponse response = client.get(Constants.AndroidConfigurationManagement.CONFIG_MGT_ENDPOINT
+ Constants.AndroidConfigurationManagement.LICENSE_ENDPOINT);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals("Expected android license agreement is not received",
"This End User License Agreement is " + "Eula.", response.getData());
}
}

@ -17,16 +17,22 @@
*/
package org.wso2.iot.integration.device.enrollment;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.iot.integration.common.*;
import org.wso2.iot.integration.common.AssertUtil;
import org.wso2.iot.integration.common.Constants;
import org.wso2.iot.integration.common.PayloadGenerator;
import org.wso2.iot.integration.common.RestClient;
import org.wso2.iot.integration.common.TestBase;
/**
* This contains testing of Android device enrollment which is necessary to run prior to all other Android related
@ -36,18 +42,22 @@ public class AndroidEnrollment extends TestBase {
private RestClient client;
private String deviceId;
@BeforeClass(alwaysRun = true, groups = { Constants.AndroidEnrollment.ENROLLMENT_GROUP}, dependsOnGroups =
Constants.MobileDeviceManagement.MOBILE_DEVICE_MANAGEMENT_GROUP)
@Factory(dataProvider = "userModeProvider")
public AndroidEnrollment(TestUserMode userMode) {
this.userMode = userMode;
}
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(TestUserMode.SUPER_TENANT_ADMIN);
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPURL, backendHTTPSURL);
super.init(userMode);
this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
}
@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());
@ -55,38 +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");
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 disEnrollment.", dependsOnMethods = {"testModifyEnrollment"})
@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 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());
}
@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);
}
}

@ -1,95 +0,0 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.iot.integration.device.mgt;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.iot.integration.common.*;
/**
* This class contains integration tests for Android device management backend services.
*/
public class AndroidDeviceManagement extends TestBase {
private RestClient client;
private JsonObject device;
@BeforeClass(alwaysRun = true, groups = {Constants.AndroidDeviceManagement.DEVICE_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(TestUserMode.SUPER_TENANT_ADMIN);
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPURL, backendHTTPSURL);
this.client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON, accessTokenString);
}
@Test(description = "Test get all android devices.", groups = Constants.AndroidDeviceManagement.DEVICE_MANAGEMENT_GROUP)
public void testGetAllDevices() throws Exception {
HttpResponse response = client.get(Constants.AndroidDeviceManagement.DEVICE_MGT_ENDPOINT);
JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals(jsonArray.size(), 1);
}
@Test(description = "Test get android device.", groups = Constants.AndroidDeviceManagement.DEVICE_MANAGEMENT_GROUP)
public void testGetDevice() throws Exception {
HttpResponse response = client.get(Constants.AndroidDeviceManagement.DEVICE_MGT_ENDPOINT + Constants.DEVICE_ID);
device = new JsonParser().parse(response.getData()).getAsJsonObject();
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertEquals(device.get(Constants.AndroidDeviceManagement.KEY_DEVICE_ID).getAsString(), Constants.DEVICE_ID);
}
@Test(description = "Test update android device.", groups = Constants.AndroidDeviceManagement.DEVICE_MANAGEMENT_GROUP,
dependsOnMethods = {"testGetDevice"})
public void testUpdateDevice() throws Exception {
device.addProperty(Constants.AndroidDeviceManagement.KEY_DEVICE_NAME, "UpdatedName");
HttpResponse response = client.put(Constants.AndroidDeviceManagement.DEVICE_MGT_ENDPOINT + Constants.DEVICE_ID,
device.toString());
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(
Constants.AndroidDeviceManagement.RESPONSE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString(),
response.getData().toString(), true);
}
@Test(description = "Test get android license.", groups = Constants.AndroidDeviceManagement.DEVICE_MANAGEMENT_GROUP)
public void testGetLicense() throws Exception {
HttpResponse response = client.get(Constants.AndroidDeviceManagement.LICENSE_ENDPOINT);
CharSequence sequence = Constants.AndroidDeviceManagement.LICENSE_SECTION;
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
Assert.assertTrue(response.getData().contains(sequence));
}
/*
@Test(description = "Test update android device applist.", groups = Constants.DeviceManagement.DEVICE_MANAGEMENT_GROUP,
dependsOnMethods = {"testGetDevice"} )
public void testUpdateAppList() throws Exception {
HttpResponse response = client.post(Constants.DeviceManagement.APP_LIST_ENDPOINT,
Constants.DeviceManagement.APPLIST_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(Constants.DeviceManagement.REQUEST_MODIFY_DEVICE_EXPECTED,
response.getData().toString(), true);
}*/
}

@ -20,11 +20,19 @@ package org.wso2.iot.integration.device.operation;
import com.google.gson.JsonObject;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.iot.integration.common.*;
import org.wso2.iot.integration.common.Constants;
import org.wso2.iot.integration.common.PayloadGenerator;
import org.wso2.iot.integration.common.RestClient;
import org.wso2.iot.integration.common.TestBase;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
/**
* This contain tests to check operations supported by Android. Test are executed against a previously enrolled device
@ -32,179 +40,241 @@ import org.wso2.iot.integration.common.*;
public class AndroidOperation extends TestBase {
private RestClient client;
@BeforeTest(alwaysRun = true, groups = { Constants.AndroidOperations.OPERATIONS_GROUP})
@Factory(dataProvider = "userModeProvider")
public AndroidOperation(TestUserMode userMode) {
this.userMode = userMode;
}
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(TestUserMode.SUPER_TENANT_ADMIN);
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPURL, backendHTTPSURL);
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());
}
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device lock operation.")
public void testLock() throws Exception {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT +
Constants.AndroidOperations.LOCK_ENDPOINT,
Constants.AndroidOperations.LOCK_OPERATION_PAYLOAD);
public void testLock() throws MalformedURLException, AutomationFrameworkException {
HttpResponse response = client
.post(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.AndroidOperations.LOCK_ENDPOINT,
Constants.AndroidOperations.LOCK_OPERATION_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
@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);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
/*
@Test(groups = Constants.AndroidOperations.OPERATIONS_GROUP, description = "Test Android getPendingOperations.")
public void testGetPendingOperations() throws Exception {
HttpResponse response = client.put(Constants.AndroidOperations.OPERATION_ENDPOINT + Constants.DEVICE_ID,
"[]");
Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_CREATED);
}*/
@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);
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);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
// //404
// @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android device information "
// + "operation.")
// public void testDeviceInfo() throws Exception {
//
// 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 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);
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());
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());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android app un-install "
+ "operation")
public void testUninstallApplication() throws MalformedURLException, AutomationFrameworkException {
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
+ Constants.AndroidOperations.UNINSTALL_APPS_ENDPOINT,
Constants.AndroidOperations.UNINSTALL_APPS_PAYLOAD);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test black list application "
+ "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());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
// //400
// @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android application list "
// + "operation.")
// public void testApplicationList() throws Exception {
// HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT +
// Constants.AndroidOperations.APPLICATION_LIST_ENDPOINT,
// Constants.AndroidOperations.APPLICATION_LIST_PAYLOAD);
// Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
// }
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test upgrade firmware operation")
public void testUpgradeFirmware()
throws FileNotFoundException, MalformedURLException, AutomationFrameworkException {
JsonObject upgradeFirmWarePayload = PayloadGenerator
.getJsonPayload(Constants.AndroidOperations.OPERATION_PAYLOAD_FILE_NAME,
Constants.AndroidOperations.UPGRADE_FIRMWARE_OPERATION);
HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT
+ Constants.AndroidOperations.UPGRADE_FIRMWARE_ENDPOINT, upgradeFirmWarePayload.toString());
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
@Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test configure VPN operation")
public void testConfigureVPN()
throws FileNotFoundException, MalformedURLException, AutomationFrameworkException {
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());
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);
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);
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
// //400
// @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android install apps operation.")
// public void testInstallApps() throws Exception {
// HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT +
// Constants.AndroidOperations.INSTALL_APPS_ENDPOINT,
// Constants.AndroidOperations.INSTALL_APPS_PAYLOAD);
// Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
// }
// //400
// @Test(groups = {Constants.AndroidOperations.OPERATIONS_GROUP}, description = "Test Android uninstall apps "
// + "operation.")
// public void testUninstallApps() throws Exception {
// HttpResponse response = client.post(Constants.AndroidOperations.OPERATION_ENDPOINT +
// Constants.AndroidOperations.UNINSTALL_APPS_ENDPOINT,
// Constants.AndroidOperations.UNINSTALL_APPS_PAYLOAD);
// Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
// }
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());
}
}
}

@ -20,12 +20,16 @@ package org.wso2.iot.integration.mobileDevice;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.junit.experimental.theories.Theories;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.iot.integration.common.*;
import org.wso2.iot.integration.common.Constants;
import org.wso2.iot.integration.common.IOTHttpClient;
import org.wso2.iot.integration.common.IOTResponse;
import org.wso2.iot.integration.common.OAuthUtil;
import org.wso2.iot.integration.common.TestBase;
import java.util.concurrent.TimeUnit;
@ -35,26 +39,35 @@ import java.util.concurrent.TimeUnit;
public class MobileDeviceManagementWithNoDevices extends TestBase {
private IOTHttpClient client;
@Factory(dataProvider = "userModeProvider")
public MobileDeviceManagementWithNoDevices(TestUserMode userMode) {
this.userMode = userMode;
}
/**
* @BeforeSuite annotation is added to run this verification before the test suite starts.
* As in IoT server, apis are published after the server startup. Due to that the generated token doesn't get
* required scope.
* This method delays test suit startup until the tokens get required scopes.
* @throws Exception
* @throws Exception Exception
*/
@BeforeSuite
public void verifyApiPublishing() throws Exception {
super.init(TestUserMode.SUPER_TENANT_ADMIN);
long startTime = System.currentTimeMillis();
while (!checkScopes(Constants.APIApplicationRegistration.PERMISSION_LIST)) {
TimeUnit.SECONDS.sleep(5);
long WAIT_TIME = 30000;
if (System.currentTimeMillis() - startTime > WAIT_TIME) {
Assert.fail("Required APIs are not deployed after waiting for " + WAIT_TIME + " time-out has happened");
}
}
}
@BeforeClass(alwaysRun = true, groups = { Constants.MobileDeviceManagement.MOBILE_DEVICE_MANAGEMENT_GROUP})
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
public void initTest() throws Exception {
String accessTokenString = "Bearer " + OAuthUtil.getOAuthToken(backendHTTPSURL, backendHTTPSURL);
super.init(userMode);
this.client = new IOTHttpClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
}
@ -69,5 +82,4 @@ public class MobileDeviceManagementWithNoDevices extends TestBase {
String tokenString = OAuthUtil.getScopes(backendHTTPSURL, backendHTTPSURL);
return tokenString.contains(permissionsList);
}
}

@ -17,16 +17,20 @@
*/
package org.wso2.iot.integration.role;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.net.util.Base64;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.context.beans.User;
import org.wso2.iot.integration.common.*;
import org.wso2.iot.integration.common.AssertUtil;
import org.wso2.iot.integration.common.Constants;
import org.wso2.iot.integration.common.IOTHttpClient;
import org.wso2.iot.integration.common.IOTResponse;
import org.wso2.iot.integration.common.PayloadGenerator;
import org.wso2.iot.integration.common.TestBase;
import javax.xml.xpath.XPathExpressionException;
import java.io.FileNotFoundException;
@ -36,7 +40,7 @@ import java.io.FileNotFoundException;
*/
public class RoleManagement extends TestBase {
private IOTHttpClient client;
private TestUserMode userMode;
private static final String ROLE_NAME = "administration";
@Factory(dataProvider = "userModeProvider")
public RoleManagement(TestUserMode userMode) {
@ -46,29 +50,23 @@ public class RoleManagement extends TestBase {
@BeforeClass(alwaysRun = true, groups = { Constants.RoleManagement.ROLE_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(userMode);
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64
.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
String accessTokenString = "Bearer " + OAuthUtil
.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(),
currentUser.getPassword());
this.client = new IOTHttpClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
}
@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 + "/administration",
PayloadGenerator.getJsonPayload(Constants.RoleManagement.ROLE_PAYLOAD_FILE_NAME,
Constants.HTTP_METHOD_PUT).toString());
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());
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
@ -83,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,
@ -94,28 +92,39 @@ public class RoleManagement extends TestBase {
@Test(description = "Test getting permissions of a role.", dependsOnMethods = {"testGetFilteredRoles"})
public void testGetRolePermissions() throws FileNotFoundException {
IOTResponse response = client
.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/administration/permissions");
.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME + "/permissions");
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
@Test(description = "Test getting role details.", dependsOnMethods = {"testGetRolePermissions"})
public void testGetRole() throws FileNotFoundException {
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT +
"/administration");
IOTResponse response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
@Test(description = "Test remove user.", dependsOnMethods = {"testGetRole"})
public void testRemoveRole() throws Exception {
IOTResponse response = client.delete(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT +"/administration");
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,
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";
response = client.get(url);
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());
}
@DataProvider
private static Object[][] userModeProvider() {
return new TestUserMode[][]{
new TestUserMode[]{TestUserMode.SUPER_TENANT_ADMIN},
new TestUserMode[]{TestUserMode.TENANT_ADMIN}
};
@Test(description = "Test remove user.", dependsOnMethods = {"testUpdateRolesOfUser"})
public void testRemoveRole() throws Exception {
IOTResponse response = client.delete(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + ROLE_NAME);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatus());
}
}
}

@ -23,17 +23,13 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import junit.framework.Assert;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.net.util.Base64;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Factory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.context.beans.User;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import org.wso2.iot.integration.common.AssertUtil;
import org.wso2.iot.integration.common.Constants;
import org.wso2.iot.integration.common.OAuthUtil;
import org.wso2.iot.integration.common.PayloadGenerator;
import org.wso2.iot.integration.common.RestClient;
import org.wso2.iot.integration.common.TestBase;
@ -44,7 +40,6 @@ import org.wso2.iot.integration.common.TestBase;
public class UserManagement extends TestBase {
private String NON_EXISTING_USERNAME = "non_exiting";
private RestClient client;
private TestUserMode userMode;
@Factory(dataProvider = "userModeProvider")
public UserManagement(TestUserMode userMode) {
@ -54,13 +49,6 @@ public class UserManagement extends TestBase {
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
public void initTest() throws Exception {
super.init(userMode);
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64
.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
String accessTokenString = "Bearer " + OAuthUtil
.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(),
currentUser.getPassword());
this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
}
@ -113,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(
@ -157,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());
}
@ -186,12 +173,4 @@ public class UserManagement extends TestBase {
Assert.assertEquals("Password of the user cannot be changed",
"\"UserImpl password by " + "username: admin was successfully changed.\"", response.getData());
}
@DataProvider
private static Object[][] userModeProvider() {
return new TestUserMode[][]{
new TestUserMode[]{TestUserMode.SUPER_TENANT_ADMIN},
new TestUserMode[]{TestUserMode.TENANT_ADMIN}
};
}
}

@ -182,5 +182,51 @@
"memoryUsage": 0
}
]
},
"UPDATE_APPLICATIONS": [
{
"id": 1,
"platform": "string",
"category": "string",
"name": "string",
"locationUrl": "string",
"imageUrl": "string",
"version": "string",
"type": "string",
"appProperties": {
},
"applicationIdentifier": "string",
"memoryUsage": 0
},
{
"id": 2,
"platform": "string",
"category": "string",
"name": "string",
"locationUrl": "string",
"imageUrl": "string",
"version": "string",
"type": "string",
"appProperties": {
},
"applicationIdentifier": "string",
"memoryUsage": 0
},
{
"id": 3,
"platform": "string",
"category": "string",
"name": "string",
"locationUrl": "string",
"imageUrl": "string",
"version": "string",
"type": "string",
"appProperties": {
},
"applicationIdentifier": "string",
"memoryUsage": 0
}
],
"GET_PENDING_OPERATIONS" : []
}

@ -14,11 +14,11 @@
"install_apps": {
"operation": {
"appIdentifier": "package_name",
"type": "enterprise/public/webapp",
"type": "enterprise",
"url": "https://www.youtube.com",
"name": "youtube"
},
"deviceIDs": []
"deviceIDs": ["d24f870f390352a41234"]
},
"notification": {
"operation": {
@ -64,5 +64,34 @@
"type": "install"
},
"deviceIDs": []
},
"black_list_application": {
"operation": {
"appIdentifiers": ["com.google", "android.studio"]
},
"deviceIDs": [
"d24f870f390352a41234"
]
},
"upgrade-firmware" : {
"operation": {
"schedule": "",
"server" : "http://www.google.lk"
},
"deviceIDs": [
"d24f870f390352a41234"
]
},
"vpn" : {
"operation": {
"serverAddress": "localhost",
"serverPort" : "9763",
"sharedSecret" : "helloWorld",
"dnsServer" : "testserver.com"
},
"deviceIDs": [
"d24f870f390352a41234"
]
}
}

@ -1,17 +1,13 @@
{
"POST": {
"roleName": "administration",
"users": [
"admin"
]
"users": []
},
"PUT": {
"roleName": "administration",
"users": [
"admin"
],
"permissions": [
"/permission/admin/device-mgt/admin/groups"
]
}
},
"UPDATE_USERS": ["admin", "testuser11"]
}

@ -43,20 +43,15 @@
<class name="org.wso2.iot.integration.device.operation.AndroidOperation"/>
</classes>
</test>
<test name="android-configuration" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.iot.integration.device.configuration.AndroidConfigurationManagement"/>
</classes>
</test>
<!--<test name="windows-enrollment" preserve-order="true" parallel="false">-->
<!--<classes>-->
<!--<class name="org.wso2.iot.integration.device.enrollment.WindowsEnrollment"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="android-device-mgt" preserve-order="false" parallel="true">-->
<!--<classes>-->
<!--<class name="org.wso2.iot.integration.device.mgt.AndroidDeviceManagement"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="android-configuration" preserve-order="true" parallel="false">-->
<!--<classes>-->
<!--<class name="org.wso2.iot.integration.device.configuration.AndroidConfigurationManagement"/>-->
<!--</classes>-->
<!--<classes>-->
<!--<class name="org.wso2.iot.integration.device.enrollment.WindowsEnrollment"/>-->
<!--</classes>-->
<!--</test>-->
<!--<test name="android-policy" preserve-order="true" parallel="false">-->
<!--<classes>-->
@ -108,4 +103,4 @@
<class name="org.wso2.iot.integration.user.UserManagement"/>
</classes>
</test>
</suite>
</suite>

@ -1596,7 +1596,7 @@
<equinox.jsp.jasper.version>1.0.400.v20120522-2049</equinox.jsp.jasper.version>
<selenium.version>2.40.0</selenium.version>
<operadriver.version>0.8.1</operadriver.version>
<carbon.automationutils.version>4.4.1</carbon.automationutils.version>
<carbon.automationutils.version>4.4.2</carbon.automationutils.version>
<xfer.version>3.3.0</xfer.version>
<jacoco.agent.version>0.7.4.201502262128</jacoco.agent.version>
<commons.logging.version>1.1.1</commons.logging.version>

Loading…
Cancel
Save