From 19b06bc8bc91ddec33755707a37ddad8eae25a58 Mon Sep 17 00:00:00 2001 From: megala21 Date: Mon, 15 May 2017 00:31:24 +0530 Subject: [PATCH 1/3] Adding android sense test cases --- .../iot/integration/common/Constants.java | 41 +- .../wso2/iot/integration/common/TestBase.java | 7 +- modules/integration/tests-integration/pom.xml | 4 + .../enrollment/AndroidSenseEnrollment.java | 146 ++ .../jmeter/AppManagerJmeterTestCase.java | 2 +- .../src/test/resources/automation.xml | 4 +- .../jmeter-scripts/AppManagerTest.jmx | 2020 ++++++++++++++--- .../NotificationManagementAPI.jmx | 4 +- .../android-sense-enrollment-payloads.json | 63 + .../src/test/resources/testng.xml | 5 + 10 files changed, 1897 insertions(+), 399 deletions(-) create mode 100644 modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidSenseEnrollment.java create mode 100644 modules/integration/tests-integration/src/test/resources/payloads/android-sense-enrollment-payloads.json diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java index 9efe6983..282d3577 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java @@ -23,7 +23,6 @@ import java.io.File; * Constants used through out the test suite are defined here. */ public final class Constants { - public static final String DEVICE_ID = "d24f870f390352a41234"; public static final String NUMBER_NOT_EQUAL_TO_DEVICE_ID = "1111"; public static final String DEVICE_IMEI = "123123123"; @@ -44,9 +43,7 @@ public final class Constants { public static final String CONTENT_TYPE = "Content-Type"; public static final String APPLICATION_SOAP_XML = "application/soap+xml; charset=utf-8"; public static final String UTF8 = "UTF-8"; - public static final String ZERO = "0"; - public static final String NULL = "[]"; - public static final String INACTIVE = "INACTIVE"; + public static final int HTTPS_ANALYTICS_PORT = 9445; public static final String HTTPS = "https"; public static final String HTTP = "http"; @@ -59,7 +56,10 @@ public final class Constants { 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:applications"; + + "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 perm:devicetype:deployment perm:android-sense:enroll"; public static final String OAUTH_TOKEN_PAYLOAD = "username=admin&password=admin" + MULTI_TENANT_OAUTH_TOKEN_PAYLOAD; @@ -71,19 +71,21 @@ public final class Constants { 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:admin:devices:view perm:android-sense:enroll 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: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:devicetype:deployment " + + "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 " @@ -298,8 +300,6 @@ public final class Constants { public static final String REQUEST_PAYLOAD_FILE_NAME = "mobile-device-mgt-payloads.json"; public static final String UPDATE_PAYLOAD_OPERATION = "UPDATE_DEVICE_INFO"; public static final String VIEW_DEVICE_TYPES_ENDPOINT = "/mdm-admin/devices/types"; - public static final String VIEW_DEVICE_RESPONSE_PAYLOAD_FILE_NAME = - "mobile-device-mgt-view-device-types-response-payloads.json"; public static final String NO_DEVICE = "{\"devices\":[],\"count\":0}"; private MobileDeviceManagement() { @@ -391,6 +391,19 @@ public final class Constants { private NotificationManagement() { throw new AssertionError(); } + } + public static final class AndroidSenseEnrollment { + public static final String ENROLLMENT_ENDPOINT = "/android_sense/1.0.0/device/"; + public static final String RETRIEVER_ENDPOINT = "analytics/tables/"; + public static final String ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT = "/api/device-mgt/v1.0/admin/devicetype/1.0.0/deploy/android_sense"; + public static final String ENROLLMENT_PAYLOAD_FILE_NAME = "android-sense-enrollment-payloads.json"; + public static final String PUBLISH_DATA_OPERATION = "PUBLISH_DATA"; + public static final String BATTERY_STATS_TABLE_NAME = "ORG_WSO2_IOT_ANDROID_BATTERY_STATS"; + public static final String IS_TABLE_EXIST_CHECK_URL = "analytics/table_exists"; + private AndroidSenseEnrollment() { + throw new AssertionError(); + } } + } diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java index 8915356a..0219aba2 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java @@ -35,6 +35,7 @@ public class TestBase { protected String backendHTTPSURL; protected String backendHTTPURL; protected String accessTokenString; + protected String accessToken; protected TestUserMode userMode; protected void init(TestUserMode userMode) throws Exception { @@ -48,9 +49,9 @@ public class TestBase { 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()); + accessToken = OAuthUtil.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(), + currentUser.getPassword()); + accessTokenString = "Bearer " + accessToken; } protected void initPublisher(String productGroupName, String instanceName, diff --git a/modules/integration/tests-integration/pom.xml b/modules/integration/tests-integration/pom.xml index 346a1fcb..b2ace0cb 100644 --- a/modules/integration/tests-integration/pom.xml +++ b/modules/integration/tests-integration/pom.xml @@ -269,6 +269,10 @@ org.wso2.carbon.automation org.wso2.carbon.automation.extensions + + org.eclipse.paho + org.eclipse.paho.client.mqttv3 + diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidSenseEnrollment.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidSenseEnrollment.java new file mode 100644 index 00000000..1c35f4f4 --- /dev/null +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidSenseEnrollment.java @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2017, 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.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.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.net.util.Base64; +import org.eclipse.paho.client.mqttv3.MqttClient; +import org.eclipse.paho.client.mqttv3.MqttConnectOptions; +import org.eclipse.paho.client.mqttv3.MqttMessage; +import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; +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.context.beans.User; +import org.wso2.carbon.automation.test.utils.http.client.HttpResponse; +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.sql.Timestamp; + +/** + * This class tests the android sense enrollment. + */ +public class AndroidSenseEnrollment extends TestBase { + private static Log log = LogFactory.getLog(AndroidSenseEnrollment.class); + private RestClient client; + private String DEVICE_ID = "AS101"; + private RestClient analyticsClient; + + @Factory(dataProvider = "userModeProvider") + public AndroidSenseEnrollment(TestUserMode userMode) { + this.userMode = userMode; + } + + @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 auth_string = "Basic " + encoded; + String anaytics_https_url = automationContext.getContextUrls().getWebAppURLHttps() + .replace("9443", String.valueOf(Constants.HTTPS_ANALYTICS_PORT)) + .replace("/t/" + automationContext.getContextTenant().getDomain(), "") + "/"; + this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); + this.analyticsClient = new RestClient(anaytics_https_url, Constants.APPLICATION_JSON, auth_string); + if (this.userMode == TestUserMode.TENANT_ADMIN) { + HttpResponse response = client + .post(Constants.AndroidSenseEnrollment.ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT, ""); + Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode()); + // Time for deploying the carbon apps + Thread.sleep(30000); + } + } + + @Test(description = "Test an Android sense device enrollment.") + public void testEnrollment() throws Exception { + HttpResponse response = client.post(Constants.AndroidSenseEnrollment.ENROLLMENT_ENDPOINT + DEVICE_ID + + "/register?deviceName=android_sense_test", ""); + // Time for deploying the carbon apps + Thread.sleep(30000); + Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); + JsonElement jsonElement = new JsonParser().parse(response.getData()); + JsonObject expectedPayloadObject = jsonElement.getAsJsonObject(); + Assert.assertNotNull("Mqtt end-point is returned with the android sense enrollment " + "payload", + expectedPayloadObject.get("mqttEndpoint")); + Assert.assertNotNull("Tenant domain is returned with the android sense enrollment " + "payload", + expectedPayloadObject.get("tenantDomain")); + + } + + @Test(description = "Test an Android sense device data publishing.", dependsOnMethods = {"testEnrollment"} ) + public void testEventPublishing() throws Exception { + String DEVICE_TYPE = "android_sense"; + String topic = automationContext.getContextTenant().getDomain() + "/" + DEVICE_TYPE + "/" + DEVICE_ID + "/data"; + int qos = 2; + String broker = "tcp://localhost:1886"; + String clientId = DEVICE_ID + ":" + DEVICE_TYPE; + MemoryPersistence persistence = new MemoryPersistence(); + MqttClient sampleClient = new MqttClient(broker, clientId, persistence); + MqttConnectOptions connOpts = new MqttConnectOptions(); + connOpts.setUserName(accessToken); + connOpts.setPassword("".toCharArray()); + connOpts.setKeepAliveInterval(120); + connOpts.setCleanSession(true); + log.info("Connecting to broker: " + broker); + sampleClient.connect(connOpts); + log.info("Connected"); + MqttMessage message = new MqttMessage(PayloadGenerator + .getJsonArray(Constants.AndroidSenseEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, + Constants.AndroidSenseEnrollment.PUBLISH_DATA_OPERATION).toString().getBytes()); + message.setQos(qos); + sampleClient.publish(topic, message); + log.info("Message is published to Mqtt Client"); + Thread.sleep(30000); + HttpResponse response = analyticsClient + .get(Constants.AndroidSenseEnrollment.IS_TABLE_EXIST_CHECK_URL + "?table=" + + Constants.AndroidSenseEnrollment.BATTERY_STATS_TABLE_NAME); + Assert.assertEquals("ORG_WSO2_IOT_ANDROID_BATTERY_STATS table does not exist. Problem with the android sense " + + "analytics", HttpStatus.SC_OK, response.getResponseCode()); + // Allow some time to perform the analytics tasks. + Thread.sleep(30000); + sampleClient.disconnect(); + log.info("Mqtt Client is Disconnected"); + + String url = Constants.AndroidSenseEnrollment.RETRIEVER_ENDPOINT + + Constants.AndroidSenseEnrollment.BATTERY_STATS_TABLE_NAME + "/"; + Timestamp timestamp = new Timestamp(System.currentTimeMillis() - 3600000); + url += timestamp.getTime() + "/" + new Timestamp(System.currentTimeMillis()).getTime() + "/0/100"; + response = analyticsClient.get(url); + JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray(); + Assert.assertEquals( + "Published event for the device with the id " + DEVICE_ID + " is not inserted to analytics table", + HttpStatus.SC_OK, response.getResponseCode()); + Assert.assertEquals( + "Published event for the device with the id " + DEVICE_ID + " is not inserted to analytics table", 1, + jsonArray.size()); + } +} diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/jmeter/AppManagerJmeterTestCase.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/jmeter/AppManagerJmeterTestCase.java index 6a729d59..dc03b500 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/jmeter/AppManagerJmeterTestCase.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/jmeter/AppManagerJmeterTestCase.java @@ -35,7 +35,7 @@ public class AppManagerJmeterTestCase { private static Log log = LogFactory.getLog(AppManagerJmeterTestCase.class); @Test(description = "This test case tests the flow of App Manager mobile-app creation and lifecycle") - public void GroupManagementTest() throws AutomationFrameworkException { + public void AppManagementTest() throws AutomationFrameworkException { URL url = Thread.currentThread().getContextClassLoader() .getResource("jmeter-scripts" + File.separator + "AppManagerTest.jmx"); JMeterTest script = new JMeterTest(new File(url.getPath())); diff --git a/modules/integration/tests-integration/src/test/resources/automation.xml b/modules/integration/tests-integration/src/test/resources/automation.xml index eddb09c1..249ba192 100644 --- a/modules/integration/tests-integration/src/test/resources/automation.xml +++ b/modules/integration/tests-integration/src/test/resources/automation.xml @@ -189,9 +189,9 @@ - + org.wso2.iot.integration.common.extensions.BrokerServerExtension org.wso2.iot.integration.common.extensions.IOTServerExtension - + org.wso2.iot.integration.common.extensions.AnalyticsServerExtension org.wso2.carbon.integration.common.extensions.usermgt.UserPopulateExtension diff --git a/modules/integration/tests-integration/src/test/resources/jmeter-scripts/AppManagerTest.jmx b/modules/integration/tests-integration/src/test/resources/jmeter-scripts/AppManagerTest.jmx index 8d937ed7..1710b70a 100644 --- a/modules/integration/tests-integration/src/test/resources/jmeter-scripts/AppManagerTest.jmx +++ b/modules/integration/tests-integration/src/test/resources/jmeter-scripts/AppManagerTest.jmx @@ -434,60 +434,6 @@ vars.put("encoded", encoded); - - - - - true - ${RelayState} - = - true - RelayState - - - true - ${SAMLRequest} - = - true - SAMLRequest - - - true - ${SSOAuthSessionID} - = - true - SSOAuthSessionID - - - - ${server} - ${port} - - - https - - samlsso - POST - true - false - true - false - HttpClient4 - false - - - - - - sessionDataKey - //input[@type='hidden'][@name='sessionDataKey']/@value - false - true - false - all - - - @@ -1112,7 +1058,7 @@ vars.put("encoded", encoded); - + @@ -1122,8 +1068,8 @@ vars.put("encoded", encoded); https UTF-8 - publisher/api/mobile/delete/${id} - DELETE + publisher/api/lifecycle/Approve/mobileapp/${id} + PUT true false true @@ -1145,8 +1091,17 @@ vars.put("encoded", encoded); + + + '${mobile-app}' mobileapp approved successfully + + Assertion.response_data + false + 16 + + - + @@ -1156,8 +1111,8 @@ vars.put("encoded", encoded); https UTF-8 - publisher/logout - GET + publisher/api/lifecycle/${encoded}/mobileapp/${id} + PUT true false true @@ -1179,166 +1134,26 @@ vars.put("encoded", encoded); + + + Cannot perform action 'Submit for Review' + + Assertion.response_data + false + 16 + + + + + 500 + + Assertion.response_code + true + 1 + + - - false - true - false - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - true - false - false - false - true - 0 - true - true - true - - - - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - true - false - false - false - true - 0 - true - true - true - - - - true - - - - false - - saveConfig - - - true - true - true - - true - true - true - true - false - true - true - false - false - false - true - false - false - false - true - 0 - true - true - true - - - - - - - - continue - - false - 1 - - 1 - 1 - 1443769286000 - 1443769286000 - false - - - - - - false - - - import org.apache.jmeter.services.FileServer; - -String basePath = FileServer.getFileServer().getBaseDir() + File.separator; -vars.put("script-path", basePath); - - - - - - - var encoded = encodeURIComponent('Submit for Review'); -vars.put("encoded", encoded); - javascript - - - - - true - - - - 12 - - 1 - id - # - false - - - + @@ -1347,68 +1162,1271 @@ vars.put("encoded", encoded); https - - publisher - GET + UTF-8 + publisher/api/lifecycle/Publish/mobileapp/${id} + PUT true false true - false + true false - - - SAMLRequest - //input[@type='hidden'][@name='SAMLRequest']/@value + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + '${mobile-app}' mobileapp published successfully + + Assertion.response_data + false + 16 + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/lifecycle/Deprecate/mobileapp/${id} + PUT + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + '${mobile-app}' mobileapp deprecated successfully + + Assertion.response_data + false + 16 + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/lifecycle/Retire/mobileapp/${id} + PUT + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + '${mobile-app}' mobileapp retired successfully + + Assertion.response_data + false + 16 + + + + + + + + ${script-path}image.png + bannerFile + image/png + + + ${script-path}image.png + screenshot1File + image/png + + + ${script-path}image.png + iconFile + image/png + + + + + + + true + ${response} + = + true + appmeta + + + false + 1WSO2Mobile + = + true + provider + + + false + enterprise + = + true + markettype + + + false + android + = + true + platform + + + false + ${mobile-app} + = + true + name + + + false + ${mobile-app} + = + true + displayName + + + false + ${mobile-app} + = + true + description + + + false + 1.1.10 + = + true + version + + + false + business + = + true + category + + + false + mobileapp + = + true + mobileapp + + + true + + = + true + visibility + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/asset/mobileapp + POST + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + App with identifer com.apkpure.aegon and version 1.1.10 already exists + + Assertion.response_data + false + 16 + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobile/delete/${id} + DELETE + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + + + + ${script-path}test.apk + file + application/vnd.android.package-archive,.apk + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobileapp/upload + POST + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + false + response + (?s)(^.*) + $1$ + + 1 + + + + + "package" : "com.apkpure.aegon", "version" : "1.1.10" + + Assertion.response_data + false + 16 + + + + + + + + ${script-path}image.png + bannerFile + image/png + + + ${script-path}image.png + screenshot1File + image/png + + + ${script-path}image.png + iconFile + image/png + + + + + + + true + ${response} + = + true + appmeta + + + false + 1WSO2Mobile + = + true + provider + + + false + enterprise + = + true + markettype + + + false + android + = + true + platform + + + false + ${mobile-app} + = + true + name + + + false + ${mobile-app} + = + true + displayName + + + false + ${mobile-app} + = + true + description + + + false + 1.1.10 + = + true + version + + + false + business + = + true + category + + + false + mobileapp + = + true + mobileapp + + + true + + = + true + visibility + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/asset/mobileapp + POST + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + "ok" : "true", "message" : "Asset created." + + Assertion.response_data + false + 16 + + + + false + id + "id" : "(.*)" + $1$ + + + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/lifecycle/${encoded}/mobileapp/${id} + PUT + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + '${mobile-app}' mobileapp submitted for review successfully + + Assertion.response_data + false + 16 + + + + false + id + "id":"(.*)" + $1$ + + + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobile/delete/${id} + DELETE + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/logout + GET + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + false + true + false + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + true + + + + false + + saveConfig + + + true + true + true + + true + true + true + true + false + true + true + false + false + false + true + false + false + false + true + 0 + true + true + true + + + + + + + + continue + + false + 1 + + 1 + 1 + 1443769286000 + 1443769286000 + false + + + + + + false + + + import org.apache.jmeter.services.FileServer; + +String basePath = FileServer.getFileServer().getBaseDir() + File.separator; +vars.put("script-path", basePath); + + + + + + + var encoded = encodeURIComponent('Submit for Review'); +vars.put("encoded", encoded); + javascript + + + + + true + + + + 12 + + 1 + id + # + false + + + + + + + ${server} + ${port} + + + https + + publisher + GET + true + false + true + false + false + + + + + + SAMLRequest + //input[@type='hidden'][@name='SAMLRequest']/@value + false + true + false + + + + + RelayState + //input[@type='hidden'][@name='RelayState']/@value + false + true + false + + + + + SSOAuthSessionID + //input[@type='hidden'][@name='SSOAuthSessionID']/@value + false + true + false + + + + + + + + true + ${RelayState} + = + true + RelayState + + + true + ${SAMLRequest} + = + true + SAMLRequest + + + true + ${SSOAuthSessionID} + = + true + SSOAuthSessionID + + + + ${server} + ${port} + + + https + + samlsso + POST + true + false + true + false + HttpClient4 + false + + + + + + sessionDataKey + //input[@type='hidden'][@name='sessionDataKey']/@value + false + true + false + all + + + + + + + + false + ${RelayState} + = + true + RelayState + + + false + ${sessionDataKey} + = + true + sessionDataKey + + + false + ${username}@${domain_name} + = + true + username + + + false + ${password} + = + true + password + + + + ${server} + ${port} + + + https + + commonauth + GET + true + false + true + false + false + + + + + + RelayState1 + //input[@type='hidden'][@name='RelayState']/@value + false + true + false + + + + + SAMLResponse + //input[@type='hidden'][@name='SAMLResponse']/@value false true false - - - RelayState - //input[@type='hidden'][@name='RelayState']/@value - false - true - false - + + + You are now redirected back to + + Assertion.response_data + false + 16 + + + + + + + + true + ${RelayState1} + = + true + RelayState + + + true + ${SAMLResponse} + = + true + SAMLResponse + + + + ${server} + ${port} + + + https + + publisher/acs + POST + true + false + true + false + false + + + + + + Assertion.response_data + false + 16 + + + + + + + + ${server} + ${port} + + + https + + /publisher/csrf.js + GET + true + false + true + false + false + + + + + + + + ${server} + ${port} + + + https + + /publisher/csrf.js + POST + true + false + true + false + false + + + + + + + FETCH-CSRF-TOKEN + 1 + + + - - - SSOAuthSessionID - //input[@type='hidden'][@name='SSOAuthSessionID']/@value - false - true - false - + + false + X-CSRF-Token + X-CSRF-Token:(.*) + $1$ + no_token + + - + + + + + ${script-path}test.apk + file + application/vnd.android.package-archive,.apk + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobileapp/upload + POST + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + false + response + (?s)(^.*) + $1$ + + 1 + + + + + "package" : "com.apkpure.aegon", "version" : "1.1.10" + + Assertion.response_data + false + 16 + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobile/isexist?name=${mobile-app} + GET + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + {"isExist" : false} + + Assertion.response_data + false + 8 + + + + + + + + ${script-path}image.png + bannerFile + image/png + + + ${script-path}image.png + screenshot1File + image/png + + + ${script-path}image.png + iconFile + image/png + + + - + true - ${RelayState} + ${response} + = + true + appmeta + + + false + 1WSO2Mobile + = + true + provider + + + false + enterprise + = + true + markettype + + + false + android + = + true + platform + + + false + ${invalid-mobile-app} + = + true + name + + + false + ${invalid-mobile-app} = true - RelayState + displayName - - true - ${SAMLRequest} + + false + ${invalid-mobile-app} = true - SAMLRequest + description - + + false + 1.1.10 + = + true + version + + + false + business + = + true + category + + + false + mobileapp + = + true + mobileapp + + true - ${SSOAuthSessionID} + = true - SSOAuthSessionID + visibility @@ -1417,59 +2435,138 @@ vars.put("encoded", encoded); https - - samlsso + UTF-8 + publisher/api/asset/mobileapp POST true false true - false - HttpClient4 + true false - - - sessionDataKey - //input[@type='hidden'][@name='sessionDataKey']/@value - false - true - false - all - + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + "Special characters found in name" + + Assertion.response_data + false + 16 + - + + + + + ${script-path}image.png + bannerFile + image/png + + + ${script-path}image.png + screenshot1File + image/png + + + ${script-path}image.png + iconFile + image/png + + + - + + true + ${response} + = + true + appmeta + + false - ${RelayState} + 1WSO2Mobile = true - RelayState + provider - + false - ${sessionDataKey} + enterprise = true - sessionDataKey + markettype - + false - ${username}@${domain_name} + android = true - username + platform - + false - ${password} + ${mobile-app} = true - password + name + + + false + ${mobile-app} + = + true + displayName + + + false + ${mobile-app} + = + true + description + + + false + 1.1.10 + = + true + version + + + false + business + = + true + category + + + false + mobileapp + = + true + mobileapp + + + true + + = + true + visibility @@ -1478,89 +2575,145 @@ vars.put("encoded", encoded); https - - commonauth - GET + UTF-8 + publisher/api/asset/mobileapp + POST true false true - false + true false - - - RelayState1 - //input[@type='hidden'][@name='RelayState']/@value - false - true - false - + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + - - - SAMLResponse - //input[@type='hidden'][@name='SAMLResponse']/@value - false - true - false - + + + "ok" : "true", "message" : "Asset created." + + Assertion.response_data + false + 16 + + + + false + id + "id" : "(.*)" + $1$ + + + + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/lifecycle/${encoded}/mobileapp/${id} + PUT + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + - You are now redirected back to + '${mobile-app}' mobileapp submitted for review successfully Assertion.response_data false 16 + + false + id + "id":"(.*)" + $1$ + + + + - + - - - true - ${RelayState1} - = - true - RelayState - - - true - ${SAMLResponse} - = - true - SAMLResponse - - + ${server} ${port} https - - publisher/acs - POST + UTF-8 + publisher/api/lifecycle/Approve/mobileapp/${id} + PUT true false true - false + true false + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + - + + '${mobile-app}' mobileapp approved successfully + Assertion.response_data false 16 - + @@ -1569,18 +2722,50 @@ vars.put("encoded", encoded); https - - /publisher/csrf.js - GET + UTF-8 + publisher/api/lifecycle/${encoded}/mobileapp/${id} + PUT true false true - false + true false - - + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + Cannot perform action 'Submit for Review' + + Assertion.response_data + false + 16 + + + + + 500 + + Assertion.response_code + true + 1 + + + + @@ -1589,13 +2774,13 @@ vars.put("encoded", encoded); https - - /publisher/csrf.js - POST + UTF-8 + publisher/api/lifecycle/Publish/mobileapp/${id} + PUT true false true - false + true false @@ -1603,32 +2788,27 @@ vars.put("encoded", encoded); - FETCH-CSRF-TOKEN - 1 + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest - - false - X-CSRF-Token - X-CSRF-Token:(.*) - $1$ - no_token - - + + + '${mobile-app}' mobileapp published successfully + + Assertion.response_data + false + 16 + - - - - - ${script-path}test.apk - file - application/vnd.android.package-archive,.apk - - - + @@ -1638,8 +2818,8 @@ vars.put("encoded", encoded); https UTF-8 - publisher/api/mobileapp/upload - POST + publisher/api/lifecycle/Deprecate/mobileapp/${id} + PUT true false true @@ -1661,18 +2841,9 @@ vars.put("encoded", encoded); - - false - response - (?s)(^.*) - $1$ - - 1 - - - "package" : "com.apkpure.aegon", "version" : "1.1.10" + '${mobile-app}' mobileapp deprecated successfully Assertion.response_data false @@ -1680,7 +2851,7 @@ vars.put("encoded", encoded); - + @@ -1690,8 +2861,8 @@ vars.put("encoded", encoded); https UTF-8 - publisher/api/mobile/isexist?name=${mobile-app} - GET + publisher/api/lifecycle/Retire/mobileapp/${id} + PUT true false true @@ -1715,15 +2886,15 @@ vars.put("encoded", encoded); - {"isExist" : false} + '${mobile-app}' mobileapp retired successfully Assertion.response_data false - 8 + 16 - + @@ -1775,21 +2946,21 @@ vars.put("encoded", encoded); false - ${invalid-mobile-app} + ${mobile-app} = true name false - ${invalid-mobile-app} + ${mobile-app} = true displayName false - ${invalid-mobile-app} + ${mobile-app} = true description @@ -1855,7 +3026,7 @@ vars.put("encoded", encoded); - "Special characters found in name" + App with identifer com.apkpure.aegon and version 1.1.10 already exists Assertion.response_data false @@ -1863,7 +3034,102 @@ vars.put("encoded", encoded); - + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobile/delete/${id} + DELETE + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + + + + + ${script-path}test.apk + file + application/vnd.android.package-archive,.apk + + + + + + + ${server} + ${port} + + + https + UTF-8 + publisher/api/mobileapp/upload + POST + true + false + true + true + false + + + + + + + X-CSRF-Token + ${X-CSRF-Token} + + + X-Requested-With + XmlHttpRequest + + + + + + false + response + (?s)(^.*) + $1$ + + 1 + + + + + "package" : "com.apkpure.aegon", "version" : "1.1.10" + + Assertion.response_data + false + 16 + + + + diff --git a/modules/integration/tests-integration/src/test/resources/jmeter-scripts/NotificationManagementAPI.jmx b/modules/integration/tests-integration/src/test/resources/jmeter-scripts/NotificationManagementAPI.jmx index ced0e6a2..f1c88d16 100644 --- a/modules/integration/tests-integration/src/test/resources/jmeter-scripts/NotificationManagementAPI.jmx +++ b/modules/integration/tests-integration/src/test/resources/jmeter-scripts/NotificationManagementAPI.jmx @@ -776,7 +776,7 @@ vars.put("base64encodedId",new String(encryptedId)); - "DEVICE_LOCATION operation did fail to execute on device androiddevice${DeviceID} with identifier notifiction_device" + DEVICE_LOCATION operation failed to execute on device androiddevice${DeviceID} Assertion.response_data false @@ -1364,7 +1364,7 @@ vars.put("base64encodedId",new String(encryptedId)); - "DEVICE_LOCATION operation did fail to execute on device androiddevice${DeviceID} with identifier notifiction_device" + DEVICE_LOCATION operation failed to execute on device androiddevice${DeviceID} Assertion.response_data false diff --git a/modules/integration/tests-integration/src/test/resources/payloads/android-sense-enrollment-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/android-sense-enrollment-payloads.json new file mode 100644 index 00000000..879be2d4 --- /dev/null +++ b/modules/integration/tests-integration/src/test/resources/payloads/android-sense-enrollment-payloads.json @@ -0,0 +1,63 @@ +{ + "PUBLISH_DATA": [{ + "event": { + "metaData": { + "owner": "admin", + "deviceId": "AS101", + "type": "battery", + "timestamp": 1494315475 + }, + "payloadData": { + "battery": 4, + "battery_state": "abc", + "battery_status": 90, + "battery_temperature": 100, + "gps_lat": 4.504343, + "gps_long": 4.504343, + "accelerometer_x": 6.6, + "accelerometer_y": 2.3, + "accelerometer_z": 4.5, + "speed_limit": 9.8, + "turn_way": "data5", + "magnetic_x": 8.9, + "magnetic_y": 6.6, + "magnetic_z": 6.6, + "gyroscope_x": 6.6, + "gyroscope_y": 8.9, + "gyroscope_z": 9.8, + "light": 2.3, + "pressure": 8.9, + "proximity": 6.6, + "gravity_x": 2.3, + "gravity_y": 6.6, + "gravity_z": 2.3, + "rotation_x": 6.6, + "rotation_y": 4.5, + "rotation_z": 6.6, + "word": "data1", + "word_sessionId": "data2", + "word_status": "data1", + "beacon_major": 70, + "beacon_minor": 45, + "beacon_proximity": "data4", + "beacon_uuid": 4, + "call_number": "data3", + "call_type": "data3", + "call_start_time": 4354643, + "call_end_time": 4354643, + "screen_state": "data1", + "audio_playing": true, + "headset_on": true, + "music_volume": 4, + "activity_type": 50, + "confidence": 45, + "sms_number": "data2", + "application_name": "data1", + "action": "data5", + "data_type": "data3", + "data_sent": 323232, + "data_received": 645565 + } + } + }] +} \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/testng.xml b/modules/integration/tests-integration/src/test/resources/testng.xml index bdc46f60..1c58a477 100644 --- a/modules/integration/tests-integration/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/src/test/resources/testng.xml @@ -89,6 +89,11 @@ + + + + + From 8ee4c2dbbac63005e683394c006bd37e19d39699 Mon Sep 17 00:00:00 2001 From: megala21 Date: Tue, 16 May 2017 14:36:11 +0530 Subject: [PATCH 2/3] Adding test cases for quick start guide --- .../iot/integration/common/Constants.java | 24 ++++- .../wso2/iot/integration/common/TestBase.java | 2 +- .../samples/MobileQSGTestCase.java | 102 ++++++++++++++++++ 3 files changed, 123 insertions(+), 5 deletions(-) create mode 100644 modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java index 96974b20..c2cee1a6 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java @@ -59,7 +59,15 @@ public final class Constants { 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:applications"; + + "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:read 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; @@ -68,8 +76,8 @@ 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 = "appm:subscribe perm:admin-groups:count perm:admin-groups:view " - + "perm:admin-users:view perm:admin:certificates:add perm:admin:certificates:delete " + public static final String PERMISSION_LIST = "appm:read appm:subscribe 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 " @@ -343,7 +351,7 @@ public final class Constants { public static final String UPDATE_POLICY_ENDPOINT = "/mdm-admin/policies/1"; public static final String REMOVE_POLICY_ENDPOINT = "/mdm-admin/policies/bulk-remove"; public static final String REMOVE_POLICY_PAYLOAD_FILE_NAME = "[1]"; - public static final String VIEW_POLICY_LIST_ENDPOINT = "/mdm-admin/policies"; + public static final String VIEW_POLICY_LIST_ENDPOINT = "/api/device-mgt/v1.0/policies"; private PolicyManagement() { throw new AssertionError(); @@ -393,4 +401,12 @@ public final class Constants { } } + + public static final class QSGManagement { + public static final String GET_MOBILE_APPS_ENDPONT = "/api/appm/publisher/v1.1/apps/mobileapp"; + + private QSGManagement() { + throw new AssertionError(); + } + } } diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java index 8915356a..3393e7cd 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/TestBase.java @@ -40,7 +40,7 @@ public class TestBase { protected void init(TestUserMode userMode) throws Exception { automationContext = new AutomationContext(Constants.AUTOMATION_CONTEXT, userMode); String tenantDomain = automationContext.getContextTenant().getDomain(); - backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants + backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants .HTTPS_GATEWAY_PORT)).replace("/t/" + tenantDomain , ""); backendHTTPURL = automationContext.getContextUrls().getWebAppURL().replace("9763", String.valueOf(Constants .HTTP_GATEWAY_PORT)).replace("/t/" + tenantDomain , ""); diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java new file mode 100644 index 00000000..a6d2e815 --- /dev/null +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017, 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.samples; + +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.engine.frameworkutils.FrameworkPathUtil; +import org.wso2.carbon.automation.test.utils.http.client.HttpResponse; +import org.wso2.iot.integration.common.Constants; +import org.wso2.iot.integration.common.RestClient; +import org.wso2.iot.integration.common.TestBase; + +import java.io.File; +import java.io.IOException; + +/** + * This class tests the functionality of the mobile qsg. + */ +public class MobileQSGTestCase extends TestBase { + private RestClient client; + + @BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP}) + public void initTest() throws Exception { + super.init(TestUserMode.SUPER_TENANT_ADMIN); + backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps(); + this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); + } + + @Test(description = "This test case tests the execution of QSG script, whether it executes without any exceptions") + public void executeQSGScript() throws IOException, InterruptedException { + String scriptPath = + FrameworkPathUtil.getCarbonHome() + File.separator + "samples" + File.separator + "mobile-qsg"; + File scriptFile = new File(scriptPath); + String[] cmdArray = new String[] { "sh", "mobile-qsg.sh" }; + Runtime.getRuntime().exec(cmdArray, null, scriptFile); + // Allow some time to finish its execution + Thread.sleep(10000); + } + + @Test(description = "This test case tests whether user and roles are created as expected", dependsOnMethods = + {"executeQSGScript"}) + public void testUserRoleCreation() throws Exception { + // Two users will be created with the quick start script, check whether those two users are created + // successfully, + String username1 = "alex"; + String url = Constants.UserManagement.USER_ENDPOINT + "/" + username1; + HttpResponse response = client.get(url); + Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); + String username2 = "chris"; + url = Constants.UserManagement.USER_ENDPOINT + "/" + username2; + response = client.get(url); + Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); + + // A single role will be created with the quick start script, checking whether that role creation happens + // without problem + String rolename = "iotMobileUser"; + response = client.get(Constants.RoleManagement.ROLE_MANAGEMENT_END_POINT + "/" + rolename); + Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); + } + + @Test(description = "This test case tests whether app-catalogue is created from qsg script", dependsOnMethods = + {"executeQSGScript"}) + public void testMobileApp() throws Exception { + RestClient appManagerRestClient = new RestClient(automationContext.getContextUrls().getWebAppURLHttps(), + Constants.APPLICATION_JSON, accessTokenString); + HttpResponse response = appManagerRestClient.get(Constants.QSGManagement.GET_MOBILE_APPS_ENDPONT); + Assert.assertEquals("Catalog mobile app is not uploaded successfully", HttpStatus.SC_OK, + response.getResponseCode()); + Assert.assertTrue("Catalog app addition through script is not successful", + response.getData().contains("Catalog")); + } + + @Test(description = "This test case tests the policy creation through qsg script", dependsOnMethods = {"executeQSGScript"}) + public void testPolicyCreation() throws Exception { + HttpResponse response = client.get(Constants.PolicyManagement.VIEW_POLICY_LIST_ENDPOINT + "?offset=0&limit=10"); + Assert.assertEquals("Policy upload view mobile-qsg script failed", HttpStatus.SC_OK, + response.getResponseCode()); + Assert.assertTrue("Android pass-code policy is not added from qsg script", + response.getData().contains("android-passcode-policy1")); + Assert.assertTrue("Windows pass-code policy is not added from qsg script", + response.getData().contains("windows-passcode-policy1")); + } +} From 1178869ef38daaba3f975a1b5a759759acb27730 Mon Sep 17 00:00:00 2001 From: megala21 Date: Tue, 16 May 2017 20:20:55 +0530 Subject: [PATCH 3/3] Updating versions --- .../iot/integration/common/Constants.java | 57 +++++++++++++++---- .../extensions/AnalyticsServerExtension.java | 2 - .../samples/MobileQSGTestCase.java | 15 ++++- .../src/test/resources/testng.xml | 5 ++ pom.xml | 6 +- 5 files changed, 66 insertions(+), 19 deletions(-) diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java index c2cee1a6..056db2eb 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/Constants.java @@ -23,7 +23,6 @@ import java.io.File; * Constants used through out the test suite are defined here. */ public final class Constants { - public static final String DEVICE_ID = "d24f870f390352a41234"; public static final String NUMBER_NOT_EQUAL_TO_DEVICE_ID = "1111"; public static final String DEVICE_IMEI = "123123123"; @@ -44,9 +43,7 @@ public final class Constants { public static final String CONTENT_TYPE = "Content-Type"; public static final String APPLICATION_SOAP_XML = "application/soap+xml; charset=utf-8"; public static final String UTF8 = "UTF-8"; - public static final String ZERO = "0"; - public static final String NULL = "[]"; - public static final String INACTIVE = "INACTIVE"; + public static final int HTTPS_ANALYTICS_PORT = 9445; public static final String HTTPS = "https"; public static final String HTTP = "http"; @@ -67,7 +64,32 @@ public final class Constants { + "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:read 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"; + + "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 perm:devicetype:deployment perm:android-sense:enroll"; public static final String OAUTH_TOKEN_PAYLOAD = "username=admin&password=admin" + MULTI_TENANT_OAUTH_TOKEN_PAYLOAD; @@ -79,9 +101,10 @@ public final class Constants { public static final String PERMISSION_LIST = "appm:read appm:subscribe 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:admin:devices:view perm:android-sense:enroll 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 " @@ -91,8 +114,8 @@ public final class Constants { + "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:devices:view perm:devicetype:deployment 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 " @@ -306,8 +329,6 @@ public final class Constants { public static final String REQUEST_PAYLOAD_FILE_NAME = "mobile-device-mgt-payloads.json"; public static final String UPDATE_PAYLOAD_OPERATION = "UPDATE_DEVICE_INFO"; public static final String VIEW_DEVICE_TYPES_ENDPOINT = "/mdm-admin/devices/types"; - public static final String VIEW_DEVICE_RESPONSE_PAYLOAD_FILE_NAME = - "mobile-device-mgt-view-device-types-response-payloads.json"; public static final String NO_DEVICE = "{\"devices\":[],\"count\":0}"; private MobileDeviceManagement() { @@ -399,7 +420,19 @@ public final class Constants { private NotificationManagement() { throw new AssertionError(); } + } + public static final class AndroidSenseEnrollment { + public static final String ENROLLMENT_ENDPOINT = "/android_sense/1.0.0/device/"; + public static final String RETRIEVER_ENDPOINT = "analytics/tables/"; + public static final String ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT = "/api/device-mgt/v1.0/admin/devicetype/1.0.0/deploy/android_sense"; + public static final String ENROLLMENT_PAYLOAD_FILE_NAME = "android-sense-enrollment-payloads.json"; + public static final String PUBLISH_DATA_OPERATION = "PUBLISH_DATA"; + public static final String BATTERY_STATS_TABLE_NAME = "ORG_WSO2_IOT_ANDROID_BATTERY_STATS"; + public static final String IS_TABLE_EXIST_CHECK_URL = "analytics/table_exists"; + private AndroidSenseEnrollment() { + throw new AssertionError(); + } } public static final class QSGManagement { diff --git a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/AnalyticsServerExtension.java b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/AnalyticsServerExtension.java index 23e932c0..3f9693a0 100644 --- a/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/AnalyticsServerExtension.java +++ b/modules/integration/tests-common/integration-common/src/main/java/org/wso2/iot/integration/common/extensions/AnalyticsServerExtension.java @@ -63,8 +63,6 @@ public class AnalyticsServerExtension extends ExecutionListenerExtension { try { if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) { String carbonHome = serverManager.startServer("analytics"); - log.info(carbonHome); - System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome); } } catch (Exception e) { handleException("Fail to start carbon server ", e); diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java index a6d2e815..085abc9e 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/samples/MobileQSGTestCase.java @@ -20,6 +20,7 @@ package org.wso2.iot.integration.samples; import junit.framework.Assert; import org.apache.commons.httpclient.HttpStatus; +import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.wso2.carbon.automation.engine.context.TestUserMode; @@ -37,12 +38,16 @@ import java.io.IOException; */ public class MobileQSGTestCase extends TestBase { private RestClient client; + private String username1; + private String username2; @BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP}) public void initTest() throws Exception { super.init(TestUserMode.SUPER_TENANT_ADMIN); backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps(); this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString); + username1 = "alex"; + username2 = "chris"; } @Test(description = "This test case tests the execution of QSG script, whether it executes without any exceptions") @@ -61,11 +66,9 @@ public class MobileQSGTestCase extends TestBase { public void testUserRoleCreation() throws Exception { // Two users will be created with the quick start script, check whether those two users are created // successfully, - String username1 = "alex"; String url = Constants.UserManagement.USER_ENDPOINT + "/" + username1; HttpResponse response = client.get(url); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); - String username2 = "chris"; url = Constants.UserManagement.USER_ENDPOINT + "/" + username2; response = client.get(url); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); @@ -99,4 +102,12 @@ public class MobileQSGTestCase extends TestBase { Assert.assertTrue("Windows pass-code policy is not added from qsg script", response.getData().contains("windows-passcode-policy1")); } + + @AfterClass(alwaysRun = true) + public void tearDown() throws Exception { + String url = Constants.UserManagement.USER_ENDPOINT + "/" + username1; + client.delete(url); + url = Constants.UserManagement.USER_ENDPOINT + "/" + username2; + client.delete(url); + } } diff --git a/modules/integration/tests-integration/src/test/resources/testng.xml b/modules/integration/tests-integration/src/test/resources/testng.xml index 1c58a477..cb203e09 100644 --- a/modules/integration/tests-integration/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/src/test/resources/testng.xml @@ -94,6 +94,11 @@ + + + + + diff --git a/pom.xml b/pom.xml index 5d2cbd21..80357631 100644 --- a/pom.xml +++ b/pom.xml @@ -1513,7 +1513,7 @@ - 2.0.64 + 2.0.65 [2.0.0, 3.0.0) @@ -1521,7 +1521,7 @@ - 3.0.34 + 3.0.35 6.1.80 @@ -1631,7 +1631,7 @@ 1.2.25 - 1.4.4 + 1.4.8 5.1.4