Add integration test to iot-community

feature/operation-template
Gimhan Wijayawardana 2 years ago
parent 2b9f267c48
commit ae9d376c78

@ -0,0 +1,238 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
~
~ Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
~
~ Licensed under the Entgra Commercial License, Version 1.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://entgra.io/licenses/entgra-commercial/1.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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.entgra.product.community</groupId>
<artifactId>integration-test</artifactId>
<version>5.1.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>io.entgra.product.community.iot.test.integration</artifactId>
<name>Entgra IoT Community - Integration Test Module</name>
<description>Integration Tests for Entgra IoT Community Product</description>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<argLine>-Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m</argLine>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng-server-mgt.xml</suiteXmlFile>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
<skipTests>${skipTests}</skipTests>
<systemProperties>
<property>
<name>maven.test.haltafterfailure</name>
<value>false</value>
</property>
<property>
<name>java.io.tmpdir</name>
<value>${project.build.directory}/</value>
</property>
<property>
<name>carbon.zip</name>
<value>
${basedir}/../../distribution/iot-community/target/${entgra-iot-community}.zip
</value>
</property>
<property>
<name>framework.resource.location</name>
<value>
${basedir}/src/test/resources/
</value>
</property>
<property>
<name>server.list</name>
<value>
IOT
</value>
</property>
<property>
<name>usedefaultlisteners</name>
<value>false</value>
</property>
<sec.verifier.dir>${project.build.directory}/security-verifier/</sec.verifier.dir>
<instr.file>${basedir}/src/test/resources/instrumentation.txt</instr.file>
<filters.file>${basedir}/src/test/resources/filters.txt</filters.file>
</systemProperties>
<workingDirectory>${basedir}/target</workingDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-secVerifier</id>
<phase>compile</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/security-verifier</outputDirectory>
<includeTypes>aar</includeTypes>
<includeArtifactIds>SecVerifier</includeArtifactIds>
<stripVersion>true</stripVersion>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources-jks</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/test/resources/keystores/products
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/tobeCopied/${entgra-iot-community}/repository/resources/security/
</directory>
<includes>
<include>**/*.jks</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-stratos-jks</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/test/resources/keystores/stratos
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/tobeCopied/${entgra-iot-community}/repository/resources/security/
</directory>
<includes>
<include>**/*.jks</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-axis2files</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/test/resources/axis2config
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/tobeCopied/${entgra-iot-community}/repository/conf/axis2/
</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-resources-mar</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/src/test/resources/client/modules
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/tobeCopied/${entgra-iot-community}/repository/deployment/client/modules
</directory>
<includes>
<include>**/*.mar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.automation</groupId>
<artifactId>org.wso2.carbon.automation.engine</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automation</groupId>
<artifactId>org.wso2.carbon.automation.test.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automationutils</groupId>
<artifactId>org.wso2.carbon.integration.common.extensions</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automation</groupId>
<artifactId>org.wso2.carbon.automation.extensions</artifactId>
</dependency>
</dependencies>
<properties>
<skipTests>false</skipTests>
</properties>
</project>

@ -0,0 +1,49 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.testng.Assert;
/**
* This class contains methods to make assertions easier and which are not available out of the box, from testng.
*/
public class AssertUtil {
/**
* This can be used to compare if to json strings are matched or not.
*
* @param expectedJsonPayload the expected json string.
* @param realPayload real json string.
* @param mustMatch If the real and expected must match, in order to become the test successful or not.
*/
public static void jsonPayloadCompare(String expectedJsonPayload, String realPayload, boolean mustMatch) {
JsonElement jsonElement = new JsonParser().parse(expectedJsonPayload);
JsonObject expectedPayloadObject = jsonElement.getAsJsonObject();
jsonElement = new JsonParser().parse(realPayload);
JsonObject realPayloadObject = jsonElement.getAsJsonObject();
if (mustMatch) {
Assert.assertTrue(realPayloadObject.equals(expectedPayloadObject));
} else {
Assert.assertFalse(realPayloadObject.equals(expectedPayloadObject));
}
}
}

@ -0,0 +1,510 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
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";
public static final String AUTOMATION_CONTEXT = "IOT";
public static final String APPLICATION_JSON = "application/json";
public static final String APPLICATION_ZIP = "application/zip";
public static final String APPLICATION_URL_ENCODED = "application/x-www-form-urlencoded";
public static final String OAUTH_CLIENT_ID = "client_id";
public static final String OAUTH_CLIENT_SECRET = "client_secret";
public static final String OAUTH_ACCESS_TOKEN = "access_token";
public static final String SCOPE = "scope";
public static final String ANDROID_DEVICE_TYPE = "android";
public static final String HTTP_METHOD_POST = "POST";
public static final String HTTP_METHOD_PUT = "PUT";
public static final String HTTP_METHOD_GET = "GET";
public static final String HTTP_METHOD_DELETE = "DELETE";
public static final String DEVICE_IDENTIFIER_KEY = "deviceIdentifier";
public static final String DEVICE_IDENTIFIERS_KEY = "deviceIDs";
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 int HTTPS_ANALYTICS_PORT = 9445;
public static final String HTTPS = "https";
public static final String HTTP = "http";
public static final int HTTPS_GATEWAY_PORT = 8243;
public static final int HTTP_GATEWAY_PORT = 8280;
public static final class APIApplicationRegistration {
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: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:devicetype:deployment "
+ "perm:android-sense:enroll perm:admin:device-type perm:device-types:events "
+ "perm:device-types:events:view perm:device-types:types perm:device:enroll perm:device:disenroll "
+
"perm:device:modify perm:device:operations perm:device:publish-event perm:devices:operations " +
"perm:devices:operations perm:firealarm:enroll ";
public static final String OAUTH_TOKEN_PAYLOAD = "username=admin&password=admin" +
MULTI_TENANT_OAUTH_TOKEN_PAYLOAD;
private static StringBuffer dynamicClientPayloadBuffer = new StringBuffer();
public static final String API_APP_REGISTRATION_PAYLOAD = dynamicClientPayloadBuffer.append("{ \n"
+
" \"applicationName\":\"app_123456\",\n" +
" \"isAllowedToAllDomains\":false,\n"
+
" \"tags\":[\"android\", \"device_management\"],\n" +
" \"isMappingAnExistingOAuthApp\":false\n"
+ "}")
.toString();
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:device-type " +
"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:events perm:device-types:events:view " +
"perm:device-types:features perm:device-types:types perm:device:disenroll perm:device:enroll " +
"perm:device:modify perm:device:operations perm:device:publish-event " +
"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:firealarm:enroll 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();
}
}
public static final class AndroidEnrollment {
public static final String ENROLLMENT_PAYLOAD_FILE_NAME = "android-enrollment-payloads.json";
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();
}
}
public static final class AndroidPolicy {
public static final String POLICY_RESPONSE_PAYLOAD_FILE_NAME = "android-policy-response-payloads.json";
public static final String POLICY_ENDPOINT = "/mdm-android-agent/policy/";
public static final String POLICY_GROUP = "android-policy";
public static final String GET_EFFECTIVE_POLICY = "getEffectivePolicy";
private AndroidPolicy() {
throw new AssertionError();
}
}
public static final class WindowsEnrollment {
public static final String DISCOVERY_GET_URL = "/mdm-windows-agent/services/discovery/get";
public static final String DISCOVERY_POST_URL = "/mdm-windows-agent/services/discovery/post";
public static final String BSD_URL = "/mdm-windows-agent/services/federated/bst/authentication";
public static final String MS_EXCEP = "/mdm-windows-agent/services/certificatepolicy/xcep";
public static final String WINDOWS_ENROLLMENT_GROUP = "windows-enrollment";
public static final String WSTEP_URL = "/mdm-windows-agent/services/deviceenrolment/wstep";
public static final String SYNC_ML_URL = "/mdm-windows-agent/services/syncml/devicemanagement/request";
public static final String DISCOVERY_POST_FILE = "windows" + File.separator + "enrollment" + File
.separator + "discovery-post.xml";
public static final String MS_XCEP_FILE =
"windows" + File.separator + "enrollment" + File.separator + "ms_xcep.xml";
public static final String WS_STEP_FILE =
"windows" + File.separator + "enrollment" + File.separator + "wstep.xml";
public static final String BSD_PAYLOAD =
"{\"credentials\" : {\"username\" : \"admin\", \"email\" : \"admin@wso2.com\", " +
"\"password\" : \"admin\", \"ownership\" : \"BYOD\", " +
"\"token\" : \"cbe53efd46ec612c456540f8dfef5428\"}}";
private WindowsEnrollment() {
throw new AssertionError();
}
}
public static final class AndroidOperations {
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";
public static final String CAMERA_OPERATION = "control-camera";
public static final String CAMERA_OPERATION_PAYLOAD = "{\n" + " \"operation\": {\n"
+ " \"enabled\": false\n" + " },\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\" \n"
+ " ]\n" + "}";
public static final String WIPE_DATA_OPERATION = "wipe_data";
public static final String WIPE_DATA_OPERATION_PAYLOAD = "wipe_data";
public static final String INSTALL_APPS_OPERATION = "install_apps";
public static final String NOTIFICATION_OPERATION = "notification";
public static final String WIFI_OPERATION = "wifi";
public static final String ENCRYPT_OPERATION = "encrypt";
public static final String CHANGE_LOCK_OPERATION = "unlock-devices";
public static final String PASSWORD_POLICY_OPERATION = "password_policy";
public static final String WEB_CLIP_OPERATION = "web_clip";
public static final String OPERATION_ENDPOINT = "/api/device-mgt/android/v1.0/admin/devices/";
public static final String UNLOCK_ENDPOINT = "unlock-devices";
public static final String UNLOCK_OPERATION_PAYLOAD = PAYLOAD_COMMON;
public static final String LOCK_ENDPOINT = "lock-devices";
public static final String LOCK_OPERATION_PAYLOAD = "{ \"deviceIDs\": [\"" + DEVICE_ID + "\"],"
+ "\"operation\": { \"message\": \"string\", \"hardLockEnabled\": false }}";
public static final String LOCATION_ENDPOINT = "location";
public static final String LOCATION_PAYLOAD = PAYLOAD_COMMON;
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_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;
public static final String WIPE_DATA_ENDPOINT = "wipe";
public static final String WIPE_DATA_PAYLOAD = "{\n" + " \"operation\": {\n" + " \"pin\": \"string\"\n"
+ " },\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n" + " ]\n" + "}";
public static final String APPLICATION_LIST_ENDPOINT = "applications";
public static final String APPLICATION_LIST_PAYLOAD = PAYLOAD_COMMON;
public static final String RING_ENDPOINT = "ring";
public static final String RING_PAYLOAD = PAYLOAD_COMMON;
public static final String MUTE_ENDPOINT = "mute";
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" + "}";
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\": \"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"
+ " ],\n" + " \"operation\": {\n" + " \"messageText\": \"string\",\n"
+ " \"messageTitle\": \"string\"\n" + " }\n" + "}";
public static final String WIFI_ENDPOINT = "configure-wifi";
public static final String WIFI_PAYLOAD = "{\n" + " \"operation\": {\n" + " \"ssid\": \"string\",\n"
+ " \"password\": \"string\"\n" + " },\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n"
+ " ]\n" + "}";
public static final String ENCRYPT_ENDPOINT = "encrypt-storage";
public static final String ENCRYPT_PAYLOAD = "{\n" + " \"operation\": {\n" + " \"encrypted\": false\n"
+ " },\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n" + " ]\n" + "}";
public static final String REBOOT_ENDPOINT = "reboot";
public static final String REBOOT_PAYLOAD = PAYLOAD_COMMON;
;
public static final String CHANGE_LOCK_ENDPOINT = "change-lock-code";
public static final String CHANGE_LOCK_PAYLOAD = "{\n" + " \"operation\": {\n" + " \"lockCode\": \"0000\"\n"
+ " },\n" + " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n" + " ]\n" + "}\n";
public static final String PASSWORD_POLICY_ENDPOINT = "set-password-policy";
public static final String PASSWORD_POLICY_PAYLOAD = "{\n" + " \"operation\": {\n"
+ " \"maxFailedAttempts\": 0,\n" + " \"minLength\": 0,\n" + " \"pinHistory\": 0,\n"
+ " \"minComplexChars\": 0,\n" + " \"maxPINAgeInDays\": 0,\n"
+ " \"requireAlphanumeric\": false,\n" + " \"allowSimple\": false\n" + " },\n"
+ " \"deviceIDs\": [\n" + " \"" + DEVICE_ID + "\"\n" + " ]\n" + "}";
public static final String WEB_CLIP_ENDPOINT = "set-webclip";
public static final String WEB_CLIP_PAYLOAD = "{\n" + " \"operation\": {\n" + " \"identity\": \"string\",\n"
+ " \"title\": \"string\",\n" + " \"type\": \"string\"\n" + " },\n" + " \"deviceIDs\": [\n"
+ " \"" + DEVICE_ID + "\"\n" + " ]\n" + "}";
private AndroidOperations() {
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 = "/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";
private AndroidConfigurationManagement() {
throw new AssertionError();
}
}
public static final class OperationManagement {
public static final String PATH_APPS = "/apps";
public static final String OPERATION_MANAGEMENT_GROUP = "api-policy-mgt";
public static final String GET_DEVICE_APPS_ENDPOINT = "/mdm-admin/operations/android/";
public static final String GET_DEVICE_OPERATIONS_ENDPOINT = "/mdm-admin/operations/android/";
private OperationManagement() {
throw new AssertionError();
}
}
public static final class MobileDeviceManagement {
public static final String MOBILE_DEVICE_MANAGEMENT_GROUP = "mobile-device-mgt";
public static final String GET_DEVICE_COUNT_ENDPOINT = "/api/device-mgt/v1.0/devices";
public static final String CHANGE_DEVICE_STATUS_ENDPOINT = "/api/device-mgt/v1.0/devices/";
public static final String NO_OF_DEVICES = "1";
public static final String GET_ALL_DEVICES_ENDPOINT = "/api/device-mgt/v1.0/devices/";
public static final String USER_DEVICE_ENDPOINT = "user-devices";
public static final String ADVANCE_SEARCH_ENDPOINT = "search-devices";
public static final String ADVANCE_SEARCH_OPERATION = "ADVANCE_SEARCH";
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 NO_DEVICE = "{\"devices\":[],\"count\":0}";
private MobileDeviceManagement() {
throw new AssertionError();
}
}
public static final class UserManagement {
public static final String USER_MANAGEMENT_GROUP = "user-mgt";
public static final String USER_NAME = "username123";
public static final String USER_ENDPOINT = "/api/device-mgt/v1.0/users";
public static final String USER_PAYLOAD_FILE_NAME = "user-payloads.json";
public static final String USER_RESPONSE_PAYLOAD_FILE_NAME = "user-response-payloads.json";
public static final String GET_ROLES_METHOD = "GET_ROLES";
public static final String RESET_PASSWORD_PAYLOAD = "RESET_PASSWORD";
private UserManagement() {
throw new AssertionError();
}
}
public static final class RoleManagement {
public static final String ROLE_MANAGEMENT_GROUP = "role-mgt";
public static final String ROLE_MANAGEMENT_END_POINT = "/api/device-mgt/v1.0/roles";
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();
}
}
public static final class PolicyManagement {
public static final String POLICY_MANAGEMENT_GROUP = "policy-mgt";
public static final String ADD_POLICY_ENDPOINT = "/mdm-admin/policies/active-policy";
public static final String POLICY_PAYLOAD_FILE_NAME = "policy-payloads.json";
public static final String POLICY_RESPONSE_PAYLOAD_FILE_NAME = "policy-response-payloads.json";
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 = "/api/device-mgt/v1.0/policies";
private PolicyManagement() {
throw new AssertionError();
}
}
public static final class FeatureManagement {
public static final String FEATURE_MANAGEMENT_GROUP = "feature-mgt";
public static final String VIEW_FEATURES_ENDPOINT = "/mdm-admin/features/android";
private FeatureManagement() {
throw new AssertionError();
}
}
public static final class LicenseManagement {
public static final String LICENSE_MANAGEMENT_GROUP = "license-mgt";
public static final String GET_LICENSE_ENDPOINT = "/mdm-admin/license/android/en_US";
public static final String LICENSE_RESPONSE_PAYLOAD_FILE_NAME = "license-response-payloads.json";
private LicenseManagement() {
throw new AssertionError();
}
}
public static final class ConfigurationManagement {
public static final String CONFIGURATION_MANAGEMENT_GROUP = "configuration-mgt";
public static final String CONFIGURATION_ENDPOINT = "/mdm-admin/configuration";
public static final String CONFIGURATION_PAYLOAD_FILE_NAME = "configuration-payloads.json";
public static final String CONFIGURATION_RESPONSE_PAYLOAD_FILE_NAME = "configuration-response-payloads.json";
private ConfigurationManagement() {
throw new AssertionError();
}
}
public static final class NotificationManagement {
public static final String NOTIFICATION_MANAGEMENT_GROUP = "notification-mgt";
public static final String NOTIFICATION_ENDPOINT = "/mdm-admin/notifications";
public static final String NOTIFICATION_PAYLOAD_FILE_NAME = "notification-payloads.json";
public static final String NOTIFICATION_RESPONSE_PAYLOAD_FILE_NAME = "notification-response-payloads.json";
public static final String NOTIFICATION_UPDATE_ENDPOINT = "/mdm-admin/notifications/1234/NEW";
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/publish-artifact/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 {
public static final String GET_MOBILE_APPS_ENDPONT = "/api/appm/publisher/v1.1/apps/mobileapp";
private QSGManagement() {
throw new AssertionError();
}
}
public static final class VirtualFireAlarmConstants {
public static final String ENROLLMENT_ENDPOINT = "/virtual_firealarm/1.0.0/device/download";
public static final String STATS_ENDPOINT = "/virtual_firealarm/1.0.0/device/stats";
public static final String PAYLOAD_FILE = "virtual-fire-alarm-enrollment-payloads.json";
public static final String ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT =
"/api/device-mgt/v1.0/admin/publish-artifact/1.0.0/deploy/virtual_firealarm";
public static final String POLICY_DATA = "POLICY_DATA";
public static final String ACTIVATE_POLICY_ENDPOINT = "/api/device-mgt/v1.0/policies/activate-policy";
public static final String APPLY_CHANGES_ENDPOINT = "/api/device-mgt/v1.0/policies/apply-changes";
}
}

@ -0,0 +1,189 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory;
import org.apache.commons.httpclient.methods.DeleteMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.Map;
/**
* This class creates a customised Http Client Class
*/
public class IOTHttpClient {
private static final String AUTHORIZATION = "Authorization";
private static Log log = LogFactory.getLog(IOTHttpClient.class);
private String backEndUrl;
private String authorizationString;
private Map<String, String> requestHeaders = new HashMap<String, String>();
public IOTHttpClient(String backEndUrl, String contentType, String authorization) {
this.backEndUrl = backEndUrl;
this.requestHeaders.put(Constants.CONTENT_TYPE, contentType);
if (authorization != null || !authorization.isEmpty()) {
this.authorizationString = authorization;
this.requestHeaders.put(AUTHORIZATION, authorization);
}
}
public String getAuthorizationString() {
return authorizationString;
}
public void setAuthorizationString(String authorizationString) {
this.authorizationString = authorizationString;
}
public void setHttpHeader(String headerName, String value) {
this.requestHeaders.put(headerName, value);
}
public String getHttpHeader(String headerName) {
return this.requestHeaders.get(headerName);
}
public void removeHttpHeader(String headerName) {
this.requestHeaders.remove(headerName);
}
public IOTResponse post(String endpoint, String body) {
HttpClient client = new HttpClient();
try {
ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory();
Protocol https = new Protocol(Constants.HTTPS, socketFactory, Constants.HTTPS_GATEWAY_PORT);
Protocol.registerProtocol(Constants.HTTPS, https);
String url = backEndUrl + endpoint;
PostMethod method = new PostMethod(url);
method.setRequestHeader(AUTHORIZATION, authorizationString);
StringRequestEntity requestEntity = new StringRequestEntity(body,
requestHeaders.get(Constants.CONTENT_TYPE), Constants.UTF8);
method.setRequestEntity(requestEntity);
IOTResponse iotResponse = new IOTResponse();
iotResponse.setStatus(client.executeMethod(method));
iotResponse.setBody(method.getResponseBodyAsString());
return iotResponse;
} catch (GeneralSecurityException e) {
log.error("Failure occurred at IOTResponse post for GeneralSecurityException", e);
} catch (IOException e) {
log.error("Failure occurred at IOTResponse post for IOException", e);
}
return null;
}
public IOTResponse put(String endpoint, String body) {
HttpClient client = new HttpClient();
try {
ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory();
Protocol https = new Protocol(Constants.HTTPS, socketFactory, Constants.HTTPS_GATEWAY_PORT);
Protocol.registerProtocol(Constants.HTTPS, https);
String url = backEndUrl + endpoint;
PutMethod method = new PutMethod(url);
method.setRequestHeader(AUTHORIZATION, authorizationString);
StringRequestEntity requestEntity = new StringRequestEntity(
body, requestHeaders.get(Constants.CONTENT_TYPE), Constants.UTF8);
method.setRequestEntity(requestEntity);
IOTResponse iotResponse = new IOTResponse();
iotResponse.setStatus(client.executeMethod(method));
iotResponse.setBody(method.getResponseBodyAsString());
return iotResponse;
} catch (GeneralSecurityException e) {
log.error("Failure occurred at IOTResponse put for GeneralSecurityException", e);
} catch (IOException e) {
log.error("Failure occurred at IOTResponse put for IO Exception", e);
}
return null;
}
public IOTResponse get(String endpoint) {
HttpClient client = new HttpClient();
try {
ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory();
Protocol https = new Protocol(Constants.HTTPS, socketFactory, Constants.HTTPS_GATEWAY_PORT);
Protocol.registerProtocol(Constants.HTTPS, https);
String url = backEndUrl + endpoint;
GetMethod method = new GetMethod(url);
method.setRequestHeader(AUTHORIZATION, authorizationString);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false));
IOTResponse iotResponse = new IOTResponse();
iotResponse.setStatus(client.executeMethod(method));
iotResponse.setBody(new String(method.getResponseBody()));
return iotResponse;
} catch (GeneralSecurityException e) {
log.error("Failure occurred at IOTResponse get for GeneralSecurityException", e);
} catch (IOException e) {
log.error("Failure occurred at IOTResponse get for IOException", e);
}
return null;
}
public IOTResponse delete(String endpoint) {
HttpClient client = new HttpClient();
try {
ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory();
Protocol https = new Protocol(Constants.HTTPS, socketFactory, Constants.HTTPS_GATEWAY_PORT);
Protocol.registerProtocol(Constants.HTTPS, https);
String url = backEndUrl + endpoint;
DeleteMethod method = new DeleteMethod(url);
method.setRequestHeader(AUTHORIZATION, authorizationString);
method.setRequestHeader(Constants.CONTENT_TYPE, requestHeaders.get(Constants.CONTENT_TYPE));
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler(3, false));
IOTResponse iotResponse = new IOTResponse();
iotResponse.setStatus(client.executeMethod(method));
iotResponse.setBody(method.getResponseBodyAsString());
return iotResponse;
} catch (GeneralSecurityException e) {
log.error("Failure occurred at IOTResponse delete for GeneralSecurityException", e);
} catch (IOException e) {
log.error("Failure occurred at IOTResponse delete for IOException", e);
}
return null;
}
}

@ -0,0 +1,45 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
/**
* This class contains the functions to handle a HTTP Response
*/
public class IOTResponse {
private int status;
private String body;
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
}

@ -0,0 +1,84 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
import org.apache.commons.net.util.Base64;
import org.json.JSONObject;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
/**
* This Util class holds method necessary to get an OAuth token.
*/
public class OAuthUtil {
public static String getScopes(String backendHTTPURL, String backendHTTPSURL) throws Exception {
return getOAuthTokenPair(backendHTTPURL, backendHTTPSURL).get(Constants.SCOPE).toString();
}
public static String getOAuthToken(String backendHTTPURL, String backendHTTPSURL) throws Exception {
return getOAuthTokenPair(backendHTTPURL, backendHTTPSURL).get(Constants.OAUTH_ACCESS_TOKEN).toString();
}
public static JSONObject getOAuthTokenPair(String backendHTTPURL, String backendHTTPSURL) throws Exception {
String AuthString = "Basic YWRtaW46YWRtaW4=";
RestClient client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON, AuthString);
HttpResponse oAuthData = client.post(Constants.APIApplicationRegistration.API_APP_REGISTRATION_ENDPOINT,
Constants.APIApplicationRegistration.API_APP_REGISTRATION_PAYLOAD);
JSONObject jsonObj = new JSONObject(oAuthData.getData());
String clientId = jsonObj.get(Constants.OAUTH_CLIENT_ID).toString();
String clientSecret = jsonObj.get(Constants.OAUTH_CLIENT_SECRET).toString();
byte[] bytesEncoded = Base64.encodeBase64((clientId + ":" + clientSecret).getBytes());
String basicAuthString = "Basic " + new String(bytesEncoded);
//Initiate a RestClient to get OAuth token
client = new RestClient(backendHTTPSURL, Constants.APPLICATION_URL_ENCODED, basicAuthString);
oAuthData = client.post(Constants.APIApplicationRegistration.TOKEN_ENDPOINT,
Constants.APIApplicationRegistration.OAUTH_TOKEN_PAYLOAD);
jsonObj = new JSONObject(oAuthData.getData());
return jsonObj;
}
/**
* To get the oauth token pair for the given auth string which is encoded in base64 format.
* @param authString encoded auth string
* @param backendHTTPURL backend http URL
* @param backendHTTPSURL backend https URL
* @return a JSON object which consist of oauth token pair
* @throws Exception Exception
*/
public static String getOAuthTokenPair(String authString, String backendHTTPURL, String backendHTTPSURL,
String username, String password) throws Exception {
RestClient client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON, "Basic " + authString);
HttpResponse oAuthData = client.post(Constants.APIApplicationRegistration.API_APP_REGISTRATION_ENDPOINT,
Constants.APIApplicationRegistration.API_APP_REGISTRATION_PAYLOAD);
JSONObject jsonObj = new JSONObject(oAuthData.getData());
String clientId = jsonObj.get(Constants.OAUTH_CLIENT_ID).toString();
String clientSecret = jsonObj.get(Constants.OAUTH_CLIENT_SECRET).toString();
byte[] bytesEncoded = Base64.encodeBase64((clientId + ":" + clientSecret).getBytes());
String basicAuthString = "Basic " + new String(bytesEncoded);
//Initiate a RestClient to get OAuth token
client = new RestClient(backendHTTPSURL, Constants.APPLICATION_URL_ENCODED, basicAuthString);
oAuthData = client.post(Constants.APIApplicationRegistration.TOKEN_ENDPOINT,
"username=" + username + "&password=" + password + Constants.APIApplicationRegistration.MULTI_TENANT_OAUTH_TOKEN_PAYLOAD);
jsonObj = new JSONObject(oAuthData.getData());
return jsonObj.get(Constants.OAUTH_ACCESS_TOKEN).toString();
}
}

@ -0,0 +1,69 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.io.IOUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
/**
* This class is used to load the necessary payloads from payload files for integration tests.
*/
public class PayloadGenerator {
private static final String PAYLOAD_LOCATION = "payloads/";
private static JsonParser parser = new JsonParser();
public static JsonObject getJsonPayload(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).getAsJsonObject();
}
public static String getJsonPayloadToString(String fileName) throws IOException {
URL url = Thread.currentThread().getContextClassLoader().getResource(PAYLOAD_LOCATION + fileName);
FileInputStream fisTargetFile = new FileInputStream(new File(url.getPath()));
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();
}
}

@ -0,0 +1,221 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.test.utils.http.client.HttpRequestUtil;
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
/**
* This is the rest client that is used to calls to APIs.
*/
public class RestClient {
private static final String AUTHORIZATION = "Authorization";
private String backEndUrl;
private String authrizationString;
private Map<String, String> requestHeaders = new HashMap<String, String>();
public RestClient(String backEndUrl, String contentType) {
this.backEndUrl = backEndUrl;
this.requestHeaders.put(Constants.CONTENT_TYPE, contentType);
}
public RestClient(String backEndUrl, String contentType, String authorization) {
this.backEndUrl = backEndUrl;
this.requestHeaders.put(Constants.CONTENT_TYPE, contentType);
if (authorization != null || !authorization.isEmpty()) {
this.authrizationString = authorization;
this.requestHeaders.put(AUTHORIZATION, authorization);
}
}
public String getAuthrizationString() {
return authrizationString;
}
public void setAuthrizationString(String authrizationString) {
this.authrizationString = authrizationString;
}
public void setHttpHeader(String headerName, String value) {
this.requestHeaders.put(headerName, value);
}
public String getHttpHeader(String headerName) {
return this.requestHeaders.get(headerName);
}
public void removeHttpHeader(String headerName) {
this.requestHeaders.remove(headerName);
}
public HttpResponse post(String endpoint, String body) throws MalformedURLException, AutomationFrameworkException {
return HttpRequestUtil.doPost(new URL(backEndUrl + endpoint), body, requestHeaders);
}
public HttpResponse put(String endpoint, String body) throws Exception {
HttpURLConnection urlConnection = null;
try {
urlConnection = (HttpURLConnection) new URL(backEndUrl + endpoint).openConnection();
try {
urlConnection.setRequestMethod("PUT");
} catch (ProtocolException e) {
throw new Exception("Shouldn\'t happen: HttpURLConnection doesn\'t support POST?? " + e.getMessage(),
e);
}
urlConnection.setDoOutput(true);
urlConnection.setDoInput(true);
urlConnection.setUseCaches(false);
urlConnection.setAllowUserInteraction(false);
Iterator entryIterator = this.requestHeaders.entrySet().iterator();
while (entryIterator.hasNext()) {
Map.Entry sb = (Map.Entry) entryIterator.next();
urlConnection.setRequestProperty((String) sb.getKey(), (String) sb.getValue());
}
OutputStream outputStream = urlConnection.getOutputStream();
try {
OutputStreamWriter sb1 = new OutputStreamWriter(outputStream, "UTF-8");
sb1.write(body);
sb1.close();
} catch (IOException e) {
throw new Exception("IOException while sending data " + e.getMessage(), e);
} finally {
if (outputStream != null) {
outputStream.close();
}
}
StringBuilder sb2 = new StringBuilder();
BufferedReader rd = null;
try {
rd = new BufferedReader(
new InputStreamReader(urlConnection.getInputStream(), Charset.defaultCharset()));
String itr;
while ((itr = rd.readLine()) != null) {
sb2.append(itr);
}
} catch (FileNotFoundException e) {
throw new Exception("IOException while reading put request data " + e.getMessage(), e);
} finally {
if (rd != null) {
rd.close();
}
}
Iterator iterator = urlConnection.getHeaderFields().keySet().iterator();
HashMap responseHeaders = new HashMap();
while (iterator.hasNext()) {
String key = (String) iterator.next();
if (key != null) {
responseHeaders.put(key, urlConnection.getHeaderField(key));
}
}
HttpResponse httpResponse =
new HttpResponse(sb2.toString(), urlConnection.getResponseCode(), responseHeaders);
return httpResponse;
} catch (IOException e) {
throw new Exception("Connection error (Is server running at " + endpoint + " ?): " + e.getMessage(), e);
} finally {
if (urlConnection != null) {
urlConnection.disconnect();
}
}
}
public HttpResponse get(String endpoint) throws Exception {
return HttpRequestUtil.doGet(backEndUrl + endpoint, requestHeaders);
}
public HttpResponse delete(String endpoint) throws Exception {
HttpURLConnection conn = null;
HttpResponse httpResponse1;
try {
URL url = new URL(backEndUrl + endpoint);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("DELETE");
conn.setDoOutput(true);
conn.setReadTimeout(30000);
Iterator entryIterator = this.requestHeaders.entrySet().iterator();
while (entryIterator.hasNext()) {
Map.Entry rd = (Map.Entry) entryIterator.next();
conn.setRequestProperty((String) rd.getKey(), (String) rd.getValue());
}
conn.connect();
StringBuilder sb1 = new StringBuilder();
BufferedReader rd1 = null;
HttpResponse httpResponse;
try {
rd1 = new BufferedReader(new InputStreamReader(conn.getInputStream(), Charset.defaultCharset()));
String ignored;
while ((ignored = rd1.readLine()) != null) {
sb1.append(ignored);
}
httpResponse = new HttpResponse(sb1.toString(), conn.getResponseCode());
httpResponse.setResponseMessage(conn.getResponseMessage());
} catch (IOException e) {
rd1 = new BufferedReader(new InputStreamReader(conn.getErrorStream(), Charset.defaultCharset()));
String line;
while ((line = rd1.readLine()) != null) {
sb1.append(line);
}
httpResponse = new HttpResponse(sb1.toString(), conn.getResponseCode());
httpResponse.setResponseMessage(conn.getResponseMessage());
} finally {
if (rd1 != null) {
rd1.close();
}
}
httpResponse1 = httpResponse;
} finally {
if (conn != null) {
conn.disconnect();
}
}
return httpResponse1;
}
}

@ -0,0 +1,102 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.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;
import javax.xml.xpath.XPathExpressionException;
/**
* This is the base test class that provides common details necessary for other test cases.
*/
public class TestBase {
protected AutomationContext automationContext;
protected String backendHTTPSURL;
protected String backendHTTPURL;
protected String accessTokenString;
protected String accessToken;
protected TestUserMode userMode;
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
.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);
accessToken = OAuthUtil.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(),
currentUser.getPassword());
accessTokenString = "Bearer " + accessToken;
}
protected void initPublisher(String productGroupName, String instanceName,
TestUserMode userMode)
throws XPathExpressionException {
automationContext = new AutomationContext(productGroupName, instanceName, userMode);
backendHTTPSURL = automationContext.getContextUrls().getBackEndUrl();
}
public String getBackendHTTPURL() {
return backendHTTPURL;
}
public void setBackendHTTPURL(String backendHTTPURL) {
this.backendHTTPURL = backendHTTPURL;
}
protected String getBackendHTTPSURL() throws XPathExpressionException {
return backendHTTPSURL;
}
protected String getSessionCookie() throws Exception {
LoginLogoutClient loginLogoutClient = new LoginLogoutClient(automationContext);
return loginLogoutClient.login();
}
protected String getServiceURL() throws XPathExpressionException {
return automationContext.getContextUrls().getServiceUrl();
}
protected AutomationContext getAutomationContext() {
return automationContext;
}
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}
};
}
}

@ -0,0 +1,83 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common.extensions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
import javax.xml.xpath.XPathExpressionException;
/**
* Test Automation server extension to start the DAS.
* This will set the carbon_home to {carbonHome}/core and port offset : 2
*/
public class AnalyticsServerExtension extends ExecutionListenerExtension {
private CustomTestServerManager serverManager;
private static final Log log = LogFactory.getLog(CarbonServerExtension.class);
private String executionEnvironment;
private AutomationContext automationContext;
private final String ANALYTICS_PORT_OFFSET = "2";
@Override
public void initiate() {
try {
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, ANALYTICS_PORT_OFFSET);
}
serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
executionEnvironment =
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
} catch (XPathExpressionException e) {
throw new RuntimeException("Error while initiating test environment", e);
}
}
@Override
public void onExecutionStart() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
String carbonHome = serverManager.startServer("analytics");
}
} catch (Exception e) {
throw new RuntimeException("Fail to start carbon server ", e);
}
}
@Override
public void onExecutionFinish() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
serverManager.stopServer();
}
} catch (Exception e) {
throw new RuntimeException("Fail to stop carbon server ", e);
}
}
}

@ -0,0 +1,85 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common.extensions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
import javax.xml.xpath.XPathExpressionException;
/**
* Test Automation server extension to start the Broker.
* This will set the carbon_home to {carbonHome}/core and port offset : 3
*/
public class BrokerServerExtension extends ExecutionListenerExtension {
private CustomTestServerManager serverManager;
private static final Log log = LogFactory.getLog(CarbonServerExtension.class);
private String executionEnvironment;
private AutomationContext automationContext;
private final String BROKER_PORT_OFFSET = "3";
@Override
public void initiate() {
try {
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, BROKER_PORT_OFFSET);
}
serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
executionEnvironment =
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
} catch (XPathExpressionException e) {
throw new RuntimeException("Error while initiating test environment", e);
}
}
@Override
public void onExecutionStart() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
String carbonHome = serverManager.startServer("broker");
log.info(carbonHome);
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
}
} catch (Exception e) {
throw new RuntimeException("Fail to start carbon server ", e);
}
}
@Override
public void onExecutionFinish() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
serverManager.stopServer();
}
} catch (Exception e) {
throw new RuntimeException("Fail to stop carbon server ", e);
}
}
}

@ -0,0 +1,428 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common.extensions;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.filefilter.DirectoryFileFilter;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.beans.User;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.engine.frameworkutils.CodeCoverageUtils;
import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil;
import org.wso2.carbon.automation.engine.frameworkutils.ReportGenerator;
import org.wso2.carbon.automation.engine.frameworkutils.TestFrameworkUtils;
import org.wso2.carbon.automation.extensions.servers.utils.ArchiveExtractor;
import org.wso2.carbon.automation.extensions.servers.utils.ClientConnectionUtil;
import org.wso2.carbon.automation.extensions.servers.utils.FileManipulator;
import org.wso2.carbon.automation.extensions.servers.utils.ServerLogReader;
import javax.xml.xpath.XPathExpressionException;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class CarbonServerManagerExtension {
private static final Log log = LogFactory.getLog(CarbonServerManagerExtension.class);
private Process process;
private String carbonHome;
private AutomationContext automationContext;
private ServerLogReader inputStreamHandler;
private ServerLogReader errorStreamHandler;
private boolean isCoverageEnable = false;
private String coverageDumpFilePath;
private int portOffset = 0;
private static final String SERVER_SHUTDOWN_MESSAGE = "Halting JVM";
private static final String SERVER_STARTUP_MESSAGE = "Mgt Console URL";
private static final long DEFAULT_START_STOP_WAIT_MS = 900000L;
private static final String CMD_ARG = "cmdArg";
private static int defaultHttpPort = Integer.parseInt("9763");
private static int defaultHttpsPort = Integer.parseInt("9443");
private static final long COVERAGE_DUMP_WAIT_TIME = 30000;
public CarbonServerManagerExtension(AutomationContext context) {
this.automationContext = context;
}
public synchronized void startServerUsingCarbonHome(String carbonHome, Map<String, String> commandMap) throws AutomationFrameworkException {
if(this.process == null) {
this.portOffset = this.checkPortAvailability(commandMap);
Process tempProcess = null;
try {
if(!commandMap.isEmpty() && this.getPortOffsetFromCommandMap(commandMap) == 0) {
System.setProperty("carbon.home", carbonHome);
}
File commandDir = new File(carbonHome);
log.info("Starting carbon server............. ");
String scriptName = TestFrameworkUtils.getStartupScriptFileName(carbonHome);
String[] parameters = this.expandServerStartupCommandList(commandMap);
String[] cmdArray;
if(System.getProperty("os.name").toLowerCase().contains("windows")) {
commandDir = new File(carbonHome + File.separator + "bin");
cmdArray = new String[]{"cmd.exe", "/c", scriptName + ".bat"};
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[])null, commandDir);
} else {
cmdArray = new String[]{"sh", "bin/" + scriptName + ".sh"};
cmdArray = this.mergePropertiesToCommandArray(parameters, cmdArray);
tempProcess = Runtime.getRuntime().exec(cmdArray, (String[])null, commandDir);
}
this.errorStreamHandler = new ServerLogReader("errorStream", tempProcess.getErrorStream());
this.inputStreamHandler = new ServerLogReader("inputStream", tempProcess.getInputStream());
this.inputStreamHandler.start();
this.errorStreamHandler.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
public void run() {
try {
CarbonServerManagerExtension.this.serverShutdown(CarbonServerManagerExtension.this.portOffset);
} catch (Exception var2) {
CarbonServerManagerExtension.log.error("Error while server shutdown ..", var2);
}
}
});
ClientConnectionUtil.waitForPort(defaultHttpPort + this.portOffset, DEFAULT_START_STOP_WAIT_MS, false, (String)this
.automationContext.getInstance().getHosts().get("default"));
long time = System.currentTimeMillis() + 60000L;
// while(true) {
// if(this.inputStreamHandler.getOutput().contains("Mgt Console URL") || System.currentTimeMillis() >= time) {
// int httpsPort = defaultHttpsPort + this.portOffset;
// String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
// User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
// ClientConnectionUtil.waitForLogin(backendURL, superUser);
// log.info("Server started successfully.");
// break;
// }
// }
int httpsPort = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.waitForLogin(backendURL, superUser);
} catch (XPathExpressionException | IOException var13) {
throw new IllegalStateException("Unable to start server", var13);
}
this.process = tempProcess;
}
}
private int checkPortAvailability(Map<String, String> commandMap) throws AutomationFrameworkException {
int portOffset = this.getPortOffsetFromCommandMap(commandMap);
if(ClientConnectionUtil.isPortOpen(defaultHttpPort + portOffset)) {
throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpPort + portOffset) + " : Port already in use");
} else if(ClientConnectionUtil.isPortOpen(defaultHttpsPort + portOffset)) {
throw new AutomationFrameworkException("Unable to start carbon server on port " + (defaultHttpsPort + portOffset) + " : Port already in use");
} else {
return portOffset;
}
}
private String[] mergePropertiesToCommandArray(String[] parameters, String[] cmdArray) {
if(parameters != null) {
cmdArray = this.mergerArrays(cmdArray, parameters);
}
return cmdArray;
}
/**
* Unzip carbon zip file and return the carbon home. Based on the coverage configuration in automation.xml
* This method will inject jacoco agent to the carbon server startup scripts.
*
* @param carbonServerZipFile - Carbon zip file, which should be specified in test module pom
* @return - carbonHome - carbon home
* @throws IOException - If pack extraction fails
*/
public synchronized String setUpCarbonHome(String carbonServerZipFile) throws IOException, AutomationFrameworkException {
if(this.process != null) {
return this.carbonHome;
} else {
int indexOfZip = carbonServerZipFile.lastIndexOf(".zip");
if(indexOfZip == -1) {
throw new IllegalArgumentException(carbonServerZipFile + " is not a zip file");
} else {
String fileSeparator = File.separator.equals("\\")?"\\":"/";
if(fileSeparator.equals("\\")) {
carbonServerZipFile = carbonServerZipFile.replace("/", "\\");
}
String extractedCarbonDir = carbonServerZipFile.substring(carbonServerZipFile.lastIndexOf(fileSeparator) + 1, indexOfZip);
FileManipulator.deleteDir(extractedCarbonDir);
String extractDir = "carbontmp" + System.currentTimeMillis();
String baseDir = System.getProperty("basedir", ".") + File.separator + "target";
log.info("Extracting carbon zip file.. ");
(new ArchiveExtractor()).extractFile(carbonServerZipFile, baseDir + File.separator + extractDir);
this.carbonHome = (new File(baseDir)).getAbsolutePath() + File.separator + extractDir + File.separator + extractedCarbonDir;
try {
this.isCoverageEnable = Boolean.parseBoolean(this.automationContext.getConfigurationValue("//coverage"));
} catch (XPathExpressionException var8) {
throw new AutomationFrameworkException("Coverage configuration not found in automation.xml", var8);
}
if(this.isCoverageEnable) {
this.instrumentForCoverage();
}
return this.carbonHome;
}
}
}
public synchronized void serverShutdown(int portOffset) throws AutomationFrameworkException {
if(this.process != null) {
log.info("Shutting down server..");
if(ClientConnectionUtil.isPortOpen(Integer.parseInt("9443") + portOffset)) {
int httpsPort = defaultHttpsPort + portOffset;
String url = null;
try {
url = this.automationContext.getContextUrls().getBackEndUrl();
} catch (XPathExpressionException var10) {
throw new AutomationFrameworkException("Get context failed", var10);
}
String backendURL = url.replaceAll("(:\\d+)", ":" + httpsPort);
try {
ClientConnectionUtil.sendForcefulShutDownRequest(backendURL, this.automationContext.getSuperTenant().getContextUser().getUserName(), this.automationContext.getSuperTenant().getContextUser().getPassword());
} catch (AutomationFrameworkException var8) {
throw new AutomationFrameworkException("Get context failed", var8);
} catch (XPathExpressionException var9) {
throw new AutomationFrameworkException("Get context failed", var9);
}
long time = System.currentTimeMillis() + 300000L;
// while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) {
// ;
// }
log.info("Server stopped successfully...");
}
this.inputStreamHandler.stop();
this.errorStreamHandler.stop();
this.process.destroy();
this.process = null;
if(this.isCoverageEnable) {
try {
log.info("Generating Jacoco code coverage...");
this.generateCoverageReport(new File(this.carbonHome + File.separator + "repository"
+ File.separator + "components" + File.separator + "plugins" + File.separator));
} catch (IOException var7) {
log.error("Failed to generate code coverage ", var7);
throw new AutomationFrameworkException("Failed to generate code coverage ", var7);
}
}
if(portOffset == 0) {
System.clearProperty("carbon.home");
}
}
}
private void generateCoverageReport(File classesDir) throws IOException, AutomationFrameworkException {
checkJacocoDataFileSizes(FrameworkPathUtil.getJacocoCoverageHome());
CodeCoverageUtils.executeMerge(FrameworkPathUtil.getJacocoCoverageHome(), FrameworkPathUtil.getCoverageMergeFilePath());
ReportGenerator reportGenerator = new ReportGenerator(new File(FrameworkPathUtil.getCoverageMergeFilePath()), classesDir, new File(CodeCoverageUtils.getJacocoReportDirectory()), (File)null);
reportGenerator.create();
log.info("Jacoco coverage dump file path : " + FrameworkPathUtil.getCoverageDumpFilePath());
log.info("Jacoco class file path : " + classesDir);
log.info("Jacoco coverage HTML report path : " + CodeCoverageUtils.getJacocoReportDirectory() + File.separator + "index.html");
}
public synchronized void restartGracefully() throws AutomationFrameworkException {
try {
int httpsPort = defaultHttpsPort + this.portOffset;
String backendURL = this.automationContext.getContextUrls().getSecureServiceUrl().replaceAll("(:\\d+)", ":" + httpsPort);
User superUser = this.automationContext.getSuperTenant().getTenantAdmin();
ClientConnectionUtil.sendGraceFullRestartRequest(backendURL, superUser.getUserName(), superUser.getPassword());
} catch (XPathExpressionException var5) {
throw new AutomationFrameworkException("restart failed", var5);
}
long time = System.currentTimeMillis() + 300000L;
// while(!this.inputStreamHandler.getOutput().contains("Halting JVM") && System.currentTimeMillis() < time) {
// ;
// }
time = System.currentTimeMillis();
while(System.currentTimeMillis() < time + 5000L) {
;
}
try {
ClientConnectionUtil.waitForPort(Integer.parseInt((String)this.automationContext.getInstance().getPorts().get("https")), (String)this.automationContext.getInstance().getHosts().get("default"));
ClientConnectionUtil.waitForLogin(this.automationContext);
} catch (XPathExpressionException var4) {
throw new AutomationFrameworkException("Connection attempt to carbon server failed", var4);
}
}
private String[] expandServerStartupCommandList(Map<String, String> commandMap) {
if(commandMap != null && commandMap.size() != 0) {
String[] cmdParaArray = null;
String cmdArg = null;
if(commandMap.containsKey("cmdArg")) {
cmdArg = (String)commandMap.get("cmdArg");
cmdParaArray = cmdArg.trim().split("\\s+");
commandMap.remove("cmdArg");
}
String[] parameterArray = new String[commandMap.size()];
int arrayIndex = 0;
Set<Map.Entry<String, String>> entries = commandMap.entrySet();
String parameter;
for(Iterator i$ = entries.iterator(); i$.hasNext(); parameterArray[arrayIndex++] = parameter) {
Map.Entry<String, String> entry = (Map.Entry)i$.next();
String key = (String)entry.getKey();
String value = (String)entry.getValue();
if(value != null && !value.isEmpty()) {
parameter = key + "=" + value;
} else {
parameter = key;
}
}
if(cmdArg != null) {
commandMap.put("cmdArg", cmdArg);
}
if(cmdParaArray != null && cmdParaArray.length != 0) {
return (String[]) ArrayUtils.addAll(parameterArray, cmdParaArray);
} else {
return parameterArray;
}
} else {
return null;
}
}
private int getPortOffsetFromCommandMap(Map<String, String> commandMap) {
return commandMap.containsKey("-DportOffset")?Integer.parseInt((String)commandMap.get("-DportOffset")):0;
}
private String[] mergerArrays(String[] array1, String[] array2) {
return (String[])ArrayUtils.addAll(array1, array2);
}
/**
* This methods will insert jacoco agent settings into startup script under JAVA_OPTS
*
* @param scriptName - Name of the startup script
* @throws IOException - throws if shell script edit fails
*/
private void insertJacocoAgentToShellScript(String scriptName) throws IOException {
String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation();
this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath();
CodeCoverageUtils.insertStringToFile(new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".sh"), new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".sh"), "-Dwso2.server.standalone=true", "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" + ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":") + " \\");
}
/**
* This methods will insert jacoco agent settings into windows bat script
*
* @param scriptName - Name of the startup script
* @throws IOException - throws if shell script edit fails
*/
private void insertJacocoAgentToBatScript(String scriptName) throws IOException {
String jacocoAgentFile = CodeCoverageUtils.getJacocoAgentJarLocation();
this.coverageDumpFilePath = FrameworkPathUtil.getCoverageDumpFilePath();
CodeCoverageUtils.insertJacocoAgentToStartupBat(new File(this.carbonHome + File.separator + "bin" + File.separator + scriptName + ".bat"), new File(this.carbonHome + File.separator + "tmp" + File.separator + scriptName + ".bat"), "-Dcatalina.base", "-javaagent:" + jacocoAgentFile + "=destfile=" + this.coverageDumpFilePath + "" + ",append=true,includes=" + CodeCoverageUtils.getInclusionJarsPattern(":"));
}
/**
* This method will check the OS and edit server startup script to inject jacoco agent
*
* @throws IOException - If agent insertion fails.
*/
private void instrumentForCoverage() throws IOException, AutomationFrameworkException {
String scriptName = TestFrameworkUtils.getStartupScriptFileName(this.carbonHome);
if(System.getProperty("os.name").toLowerCase().contains("windows")) {
this.insertJacocoAgentToBatScript(scriptName);
if(log.isDebugEnabled()) {
log.debug("Included files " + CodeCoverageUtils.getInclusionJarsPattern(":"));
log.debug("Excluded files " + CodeCoverageUtils.getExclusionJarsPattern(":"));
}
} else {
this.insertJacocoAgentToShellScript(scriptName);
}
}
/**
* To check jacoco file sizes and wait for them to get created..
*
* @param filePath File Path of the jacoco data files.
*/
private void checkJacocoDataFileSizes(String filePath) {
Collection<File> fileSetsCollection = FileUtils
.listFiles(new File(filePath), new RegexFileFilter("[^s]+(." + "(?i)(exec))$"),
DirectoryFileFilter.DIRECTORY);
for (File inputFile : fileSetsCollection) {
if (inputFile.isDirectory()) {
continue;
}
//retry to check whether exec data file is non empty.
waitForCoverageDumpFileCreation(inputFile);
}
}
/**
* This is to wait for jacoco exe file creation.
*
* @param file File that need to be created.
*/
private void waitForCoverageDumpFileCreation(File file) {
long currentTime = System.currentTimeMillis();
long waitTime = currentTime + COVERAGE_DUMP_WAIT_TIME;
while (waitTime > System.currentTimeMillis()) {
if (file.length() > 0) {
log.info("Execution data file non empty file size in KB : " + file.length() / 1024);
break;
} else {
try {
log.warn("Execution data file is empty file size in KB : " + file.length() / 1024);
Thread.sleep(500);
} catch (InterruptedException ignored) {
log.warn("Sleep interrupted ", ignored);
}
}
}
}
}

@ -0,0 +1,182 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common.extensions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.FrameworkConstants;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import javax.xml.xpath.XPathExpressionException;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class CustomTestServerManager {
protected CarbonServerManagerExtension carbonServer;
protected String carbonZip;
protected int portOffset;
protected Map<String, String> commandMap = new HashMap<String, String>();
private static final Log log = LogFactory.getLog(CustomTestServerManager.class);
protected String carbonHome;
public CustomTestServerManager(AutomationContext context) {
carbonServer = new CarbonServerManagerExtension(context);
}
public CustomTestServerManager(AutomationContext context, String carbonZip) {
carbonServer = new CarbonServerManagerExtension(context);
this.carbonZip = carbonZip;
}
public CustomTestServerManager(AutomationContext context, int portOffset) {
carbonServer = new CarbonServerManagerExtension(context);
this.portOffset = portOffset;
commandMap.put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, String.valueOf(portOffset));
}
public CustomTestServerManager(AutomationContext context, String carbonZip,
Map<String, String> commandMap) {
carbonServer = new CarbonServerManagerExtension(context);
this.carbonZip = carbonZip;
if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) {
this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND));
} else {
throw new IllegalArgumentException("portOffset value must be set in command list");
}
this.commandMap = commandMap;
}
public String getCarbonZip() {
return carbonZip;
}
public String getCarbonHome() {
return carbonHome;
}
public int getPortOffset() {
return portOffset;
}
public void configureServer() throws AutomationFrameworkException {
}
public Map<String, String> getCommands() {
return commandMap;
}
/**
* This method is called for starting a Carbon server in preparation for execution of a
* TestSuite
* <p/>
* Add the @BeforeSuite TestNG annotation in the method overriding this method
*
* @param server : The server which needs to be start.
* @return The CARBON_HOME
* @throws IOException If an error occurs while copying the deployment artifacts into the
* Carbon server
*/
public synchronized String startServer(String server)
throws AutomationFrameworkException, IOException, XPathExpressionException, InterruptedException {
if (carbonHome == null) {
if (carbonZip == null) {
carbonZip = System.getProperty(FrameworkConstants.SYSTEM_PROPERTY_CARBON_ZIP_LOCATION);
}
if (carbonZip == null) {
throw new IllegalArgumentException("carbon zip file cannot find in the given location");
}
String extractedDir = getExistingExtractedDir();
if (server.equalsIgnoreCase("core")) {
if (extractedDir == null) {
carbonHome = carbonServer.setUpCarbonHome(carbonZip);
} else {
carbonHome = extractedDir;
}
} else if (server.equalsIgnoreCase("analytics") || server.equalsIgnoreCase("broker")) {
if (extractedDir == null) {
carbonHome = carbonServer.setUpCarbonHome(carbonZip) + File.separator + "wso2" + File.separator + server;
} else {
carbonHome = extractedDir + File.separator + "wso2" + File.separator + server;
}
} else {
throw new IllegalArgumentException("Unsupported server type provided - " + server);
}
configureServer();
}
log.info("Carbon Home - " + carbonHome);
if (commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) != null) {
this.portOffset = Integer.parseInt(commandMap.get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND));
} else {
this.portOffset = 0;
}
carbonServer.startServerUsingCarbonHome(carbonHome, commandMap);
return carbonHome;
}
private String getExistingExtractedDir() {
File zipDir = new File(System.getProperty("basedir", ".") + File.separator + "target");
File[] subFiles = zipDir.listFiles();
if (subFiles != null) {
for (File subFile : subFiles) {
if (subFile.getName().startsWith("carbontmp")) {
File[] carbonServerFiles = subFile.listFiles();
if (carbonServerFiles != null) {
for (File file : carbonServerFiles) {
if (file.getName().startsWith("entgra-iot")) {
return file.getAbsolutePath();
}
}
}
}
}
}
return null;
}
/**
* Restarting server already started by the method startServer
*
* @throws AutomationFrameworkException
*/
public void restartGracefully() throws AutomationFrameworkException {
if (carbonHome == null) {
throw new AutomationFrameworkException("No Running Server found to restart. " +
"Please make sure whether server is started");
}
carbonServer.restartGracefully();
}
/**
* This method is called for stopping a Carbon server
* <p/>
* Add the @AfterSuite annotation in the method overriding this method
*
* @throws AutomationFrameworkException If an error occurs while shutting down the server
*/
public void stopServer() throws AutomationFrameworkException {
carbonServer.serverShutdown(portOffset);
}
}

@ -0,0 +1,88 @@
/*
* Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.common.extensions;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.automation.engine.annotations.ExecutionEnvironment;
import org.wso2.carbon.automation.engine.context.AutomationContext;
import org.wso2.carbon.automation.engine.context.ContextXpathConstants;
import org.wso2.carbon.automation.engine.context.TestUserMode;
import org.wso2.carbon.automation.engine.extensions.ExecutionListenerExtension;
import org.wso2.carbon.automation.extensions.ExtensionConstants;
import org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension;
import javax.xml.xpath.XPathExpressionException;
/**
* Test Automation server extension to start the IOT core.
* This will set the carbon_home to {carbonHome}/core and port offset : 0
*/
public class IOTServerExtension extends ExecutionListenerExtension {
private CustomTestServerManager serverManager;
private static final Log log = LogFactory.getLog(CarbonServerExtension.class);
private String executionEnvironment;
private AutomationContext automationContext;
private final String IOT_CORE_PORT_OFFSET = "0";
@Override
public void initiate() {
try {
automationContext = new AutomationContext("IOT", TestUserMode.SUPER_TENANT_USER);
if (getParameters().get(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND) == null) {
getParameters().put(ExtensionConstants.SERVER_STARTUP_PORT_OFFSET_COMMAND, IOT_CORE_PORT_OFFSET);
}
serverManager = new CustomTestServerManager(getAutomationContext(), null, getParameters());
executionEnvironment =
automationContext.getConfigurationValue(ContextXpathConstants.EXECUTION_ENVIRONMENT);
} catch (XPathExpressionException e) {
throw new RuntimeException("Error while initiating test environment", e);
}
}
@Override
public void onExecutionStart() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
String carbonHome = serverManager.startServer("core");
log.info(carbonHome);
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
// Need to give time for the apis to be added to the synapse configurations.
Thread.sleep(200000);
}
} catch (Exception e) {
throw new RuntimeException("Fail to start carbon server ", e);
}
}
@Override
public void onExecutionFinish() {
try {
if (executionEnvironment.equalsIgnoreCase(ExecutionEnvironment.STANDALONE.name())) {
serverManager.stopServer();
}
} catch (Exception e) {
throw new RuntimeException("Fail to stop carbon server ", e);
}
}
}

@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 - 2022 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
*
* Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
*
* Licensed under the Entgra Commercial License, Version 1.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://entgra.io/licenses/entgra-commercial/1.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.jmeter;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.annotations.Test;
import org.wso2.carbon.automation.engine.exceptions.AutomationFrameworkException;
import org.wso2.carbon.automation.extensions.jmeter.JMeterTest;
import org.wso2.carbon.automation.extensions.jmeter.JMeterTestManager;
import java.io.File;
import java.net.URL;
/**
* JMeter Test cases for Device Management APIs.
*/
public class DeviceMgtCoreAPIJmeterTestCase {
private static Log log = LogFactory.getLog(DeviceMgtCoreAPIJmeterTestCase.class);
@Test(description = "Testing the device-mgt core functionalities")
public void permutationTest() throws AutomationFrameworkException {
URL url = Thread.currentThread().getContextClassLoader().getResource(
"jmeter-scripts" + File.separator + "DeviceMgtCoreTestPlan.jmx");
JMeterTest script = new JMeterTest(new File(url.getPath()));
JMeterTestManager manager = new JMeterTestManager();
log.info("Running permutation test using jmeter scripts");
manager.runTest(script);
}
}

@ -0,0 +1,225 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
~
~ Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
~
~ Licensed under the Entgra Commercial License, Version 1.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://entgra.io/licenses/entgra-commercial/1.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.
-->
<automation xmlns="automationXMLSchema.xsd">
<!-- ================================================= -->
<!-- Parameters -->
<!-- ================================================= -->
<configurations>
<!--
Change this to edit wait time for test artifact deployment
-->
<deploymentDelay>100000</deploymentDelay>
<!--
Change this to standalone|platform|all to execute test on specific environment
-->
<executionEnvironment>standalone</executionEnvironment>
<!--
Change this to true if you want to generate coverage statistics
-->
<coverage>false</coverage>
<!--
Change this to true if you want to enable framework dashboard
-->
<frameworkDashboard>false</frameworkDashboard>
<!--
Browser type with used by framework to execute UI test, supported types - chrome|firefox|opera|ie|htmlUnit
-->
</configurations>
<tools>
<selenium>
<!-- Change to enable remote webDriver -->
<!-- URL of remote webDriver server -->
<remoteDriverUrl enable="false">http://10.100.2.51:4444/wd/hub/</remoteDriverUrl>
<!-- Type of the browser selenium tests are running" -->
<browser>
<browserType>firefox</browserType>
<!-- path to webDriver executable - required only for chrome-->
<webdriverPath enable="false">/home/test/name/webDriver</webdriverPath>
</browser>
</selenium>
</tools>
<!--
Database configuration to be used for data service testing. DB configuration in dbs files will be replaced with
below configuration at test run time
-->
<datasources>
<datasource name="dataService">
<url>jdbc:h2:testDB</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
</datasource>
<datasource name="dataService1">
<url>jdbc:h2:testDB</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<driverClassName>org.h2.Driver</driverClassName>
</datasource>
</datasources>
<security>
<!--
KeyStore which will be used for encrypting/decrypting passwords
and other sensitive information.
-->
<keystore name="wso2">
<!-- Keystore file location -->
<fileName>keystores/products/wso2carbon.jks</fileName>
<!-- Keystore type (JKS/PKCS12 etc.) -->
<type>JKS</type>
<!-- Keystore password -->
<password>wso2carbon</password>
<!-- Private Key alias -->
<keyAlias>wso2carbon</keyAlias>
<!-- Private Key password -->
<keyPassword>wso2carbon</keyPassword>
</keystore>
<!--
System wide trust-store which is used to maintain the certificates of all
the trusted parties.
-->
<truststore name="wso2">
<!-- trust-store file location -->
<fileName>client-truststore.jks</fileName>
<!-- trust-store type (JKS/PKCS12 etc.) -->
<type>JKS</type>
<!-- trust-store password -->
<password>wso2carbon</password>
</truststore>
</security>
<featureManagement>
<p2Repositories>
<repository name="localDefault">
<repository repo-id="online-repository">https://wso2.org/repo</repository>
<repository repo-id="file-repository">file:///home/krishantha/test</repository>
</repository>
</p2Repositories>
</featureManagement>
<!--
System wide users who to be registered at the test initiation
-->
<userManagement>
<superTenant>
<tenant domain="carbon.super" key="superTenant">
<admin>
<user key="superAdmin">
<userName>admin</userName>
<password>admin</password>
</user>
</admin>
<users>
<user key="user1">
<userName>testuser11</userName>
<password>testuser11</password>
</user>
<user key="user2">
<userName>testuser21</userName>
<password>testuser21</password>
</user>
</users>
</tenant>
</superTenant>
<tenants>
<tenant domain="wso2.com" key="wso2">
<admin>
<user key="admin">
<userName>admin</userName>
<password>admin</password>
</user>
</admin>
<users>
<user key="user1">
<userName>testuser11</userName>
<password>testuser11</password>
</user>
<user key="user2">
<userName>testuser21</userName>
<password>testuser21</password>
</user>
</users>
</tenant>
</tenants>
</userManagement>
<!--
This section will initiate the initial deployment of the platform required by
the test suites.
-->
<platform>
<!--
cluster instance details to be used to platform test execution
-->
<productGroup name="IOT" clusteringEnabled="false" default="true">
<instance name="iot001" type="standalone" nonBlockingTransportEnabled="false">
<hosts>
<host type="default">localhost</host>
</hosts>
<ports>
<port type="http">9763</port>
<!--<port type="https">9446</port>-->
<port type="https">9443</port>
<!--<port type="https">9445</port>-->
</ports>
<properties>
<!--<property name="webContext">admin</property>-->
</properties>
</instance>
</productGroup>
</platform>
<listenerExtensions>
<platformExecutionManager>
<extentionClasses>
<class>
<!-- <name>org.wso2.iot.integration.common.extensions.BrokerServerExtension</name>-->
<name>org.wso2.iot.integration.common.extensions.IOTServerExtension</name>
<!-- <name>org.wso2.iot.integration.common.extensions.AnalyticsServerExtension</name>-->
<!-- <name>org.wso2.carbon.integration.common.extensions.usermgt.UserPopulateExtension</name>-->
</class>
</extentionClasses>
</platformExecutionManager>
<PlatformSuiteManager>
<extentionClasses>
<!--<className>org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension</className>-->
</extentionClasses>
</PlatformSuiteManager>
<PlatformAnnotationTransferManager>
<extentionClasses>
<!--<className>org.wso2.carbon.automation.extensions.servers.carbonserver.CarbonServerExtension</className>-->
</extentionClasses>
</PlatformAnnotationTransferManager>
<PlatformTestManager>
<extentionClasses>
</extentionClasses>
</PlatformTestManager>
<PlatformReportManager>
<extentionClasses>
</extentionClasses>
</PlatformReportManager>
</listenerExtensions>
</automation>

@ -0,0 +1,565 @@
<!--
~ 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.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="automationSchema.xsd">
<xs:element name="automation">
<xs:complexType>
<xs:sequence>
<xs:element name="configurations">
<xs:annotation>
<xs:documentation>=================================================
Parameters =================================================
Browser type with used by framework to execute UI test, supported types
- chrome|firefox|opera|ie|htmlUnit
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="deploymentDelay">
<xs:annotation>
<xs:documentation>Change this to edit wait time for test
artifact deployment
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="executionEnvironment">
<xs:annotation>
<xs:documentation>Change this to product|platform/cloud to
execute test on specific environment
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:boolean" name="multiTenantMode">
<xs:annotation>
<xs:documentation>Change this to user/tenant to execute test
with user mode or tenant mode
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="coverage">
<xs:annotation>
<xs:documentation>Change this to true if you want to generate
coverage statistics
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="frameworkDashboard">
<xs:annotation>
<xs:documentation>Change this to true if you want to enable
framework dashboard
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="tools">
<xs:complexType>
<xs:sequence>
<xs:element name="selenium">
<xs:complexType>
<xs:sequence>
<xs:element name="remoteDriverUrl">
<xs:annotation>
<xs:documentation>Change to enable remote webDriver
URL of remote webDriver server
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:anyURI">
<xs:attribute type="xs:string"
name="enable"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="browser">
<xs:annotation>
<xs:documentation>Type of the browser selenium tests
are running"
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string"
name="browserType"/>
<xs:element name="webdriverPath">
<xs:annotation>
<xs:documentation>path to webDriver
executable - required only for
chrome
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string"
name="enable"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="datasources">
<xs:complexType>
<xs:sequence>
<xs:element name="datasource" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="url"/>
<xs:element type="xs:string" name="username"/>
<xs:element type="xs:string" name="password"/>
<xs:element type="xs:string" name="driverClassName"/>
</xs:sequence>
<xs:attribute type="xs:string" name="name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="security">
<xs:complexType>
<xs:sequence>
<xs:element name="keystore" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>KeyStore which will be used for
encrypting/decrypting passwords
and other sensitive information.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="fileName">
<xs:annotation>
<xs:documentation>Keystore file location
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="type">
<xs:annotation>
<xs:documentation>Keystore type (JKS/PKCS12 etc.)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="password">
<xs:annotation>
<xs:documentation>Keystore password
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="keyAlias">
<xs:annotation>
<xs:documentation>Private Key alias
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="keyPassword">
<xs:annotation>
<xs:documentation>Private Key password
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="name"/>
</xs:complexType>
</xs:element>
<xs:element name="truststore" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>System wide trust-store which is used to
maintain the certificates of all
the trusted parties.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="fileName">
<xs:annotation>
<xs:documentation>trust-store file location
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="type">
<xs:annotation>
<xs:documentation>trust-store type (JKS/PKCS12
etc.)
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element type="xs:string" name="password">
<xs:annotation>
<xs:documentation>trust-store password
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="featureManagement">
<xs:complexType>
<xs:sequence>
<xs:element name="p2Repositories">
<xs:complexType>
<xs:sequence>
<xs:element name="repository">
<xs:complexType>
<xs:sequence>
<xs:element name="repository"
maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute type="xs:string"
name="repo-id"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="name"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="userManagement">
<xs:complexType>
<xs:sequence>
<xs:element name="superTenant">
<xs:complexType>
<xs:sequence>
<xs:element name="tenant">
<xs:complexType>
<xs:sequence>
<xs:element name="admin">
<xs:complexType>
<xs:sequence>
<xs:element name="user">
<xs:complexType>
<xs:sequence>
<xs:element
type="xs:string"
name="userName"/>
<xs:element
type="xs:string"
name="password"/>
</xs:sequence>
<xs:attribute
type="xs:string"
name="key"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="users">
<xs:complexType>
<xs:sequence>
<xs:element name="user"
maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element
type="xs:string"
name="userName"/>
<xs:element
type="xs:string"
name="password"/>
</xs:sequence>
<xs:attribute
type="xs:string"
name="key"
use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="key"
use="required"/>
<xs:attribute type="xs:string" name="domain"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="tenants">
<xs:complexType>
<xs:sequence>
<xs:element name="tenant" maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="admin">
<xs:complexType>
<xs:sequence>
<xs:element name="user">
<xs:complexType>
<xs:sequence>
<xs:element
type="xs:string"
name="userName"/>
<xs:element
type="xs:string"
name="password"/>
</xs:sequence>
<xs:attribute
type="xs:string"
name="key"
use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="users">
<xs:complexType>
<xs:sequence>
<xs:element name="user"
maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element
type="xs:string"
name="userName"/>
<xs:element
type="xs:string"
name="password"/>
</xs:sequence>
<xs:attribute
type="xs:string"
name="key"
use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="key"
use="required"/>
<xs:attribute type="xs:string" name="domain"
use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="platform">
<xs:complexType>
<xs:choice>
<xs:element name="productGroup" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:choice maxOccurs="unbounded" minOccurs="1">
<xs:element name="instance">
<xs:complexType>
<xs:sequence>
<xs:element name="hosts">
<xs:complexType>
<xs:sequence>
<xs:element name="host"
maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension
base="xs:string">
<xs:attribute
type="xs:string"
name="type"
use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ports">
<xs:complexType>
<xs:sequence>
<xs:element name="port"
maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension
base="xs:string">
<xs:attribute
type="xs:string"
name="type"
use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="properties">
<xs:complexType>
<xs:sequence>
<xs:element name="property"
maxOccurs="unbounded"
minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension
base="xs:string">
<xs:attribute
type="xs:string"
name="name"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute type="xs:string" name="name"
use="required"/>
<xs:attribute type="xs:string" name="type"
use="required"/>
<xs:attribute type="xs:boolean"
name="nonBlockingTransportEnabled"
use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute type="xs:string" name="name"/>
<xs:attribute type="xs:string" name="clusteringEnabled"/>
<xs:attribute type="xs:boolean" name="default"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:element name="listenerExtensions">
<xs:complexType>
<xs:sequence>
<xs:element name="platformExecutionManager">
<xs:complexType>
<xs:sequence>
<xs:element name="extentionClasses">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="className"
maxOccurs="unbounded"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PlatformSuiteManager">
<xs:complexType>
<xs:sequence>
<xs:element name="extentionClasses">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="className"
maxOccurs="unbounded"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PlatformAnnotationTransferManager">
<xs:complexType>
<xs:sequence>
<xs:element name="extentionClasses">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="className"
maxOccurs="unbounded"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PlatformTestManager">
<xs:complexType>
<xs:sequence>
<xs:element name="extentionClasses">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="className"
maxOccurs="unbounded"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PlatformReportManager">
<xs:complexType>
<xs:sequence>
<xs:element name="extentionClasses">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="className"
maxOccurs="unbounded"
minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

@ -0,0 +1,23 @@
-org.wso2.carbon.caching.core.identity.*
-org.wso2.carbon.caching.core.permissiontree.*
-org.wso2.carbon.caching.infinispan.*
-org.wso2.carbon.event.core.internal.delivery.jms.*
-org.wso2.carbon.event.core.qpid.*
-org.wso2.carbon.registry.synchronization.*
-*.stub*
-*.stub_
-*.stub_4.0.0
-*.stub-
-org.eclipse.*
-*.equinox.*
-org.wso2.carbon.user.core.*
-samples.*
-*.log4j*
-*.axis2*
-*.ui*
-*.tenant*
-*.stratos*
-*.eventing*
-*tests-transports*
-org.wso2.carbon.mediation.statistics*
-*startup*

@ -0,0 +1,8 @@
io.entgra.power.meter.logger_
io.entgra.meter.request_
io.entgra.device.mgt.plugin.power.meter_
io.entgra.tableau.integration_
io.entgra.iot.ami.communication.adaptor_
io.entgra.iot.dlms_
io.entgra.iot.iec_
io.entgra.iot.sms_

@ -0,0 +1,37 @@
#
# Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
#
# Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
#
# Licensed under the Entgra Commercial License, Version 1.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://entgra.io/licenses/entgra-commercial/1.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.
#
log4j.rootLogger=INFO, console, Default
log4j.logger.org.wso2=INFO
log4j.logger.org.apache.axis2.deployment.ModuleDeployer=ERROR
#Automation file apender
log4j.appender.Default=org.apache.log4j.RollingFileAppender
log4j.appender.Default.File=logs/automation.log
log4j.appender.Default.Append=true
log4j.appender.Default.MaxFileSize=10MB
log4j.appender.Default.MaxBackupIndex=10
log4j.appender.Default.layout=org.apache.log4j.PatternLayout
log4j.appender.Default.layout.ConversionPattern=%d{ISO8601} %-5p [%c] - %m%n
#Automation console apender
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%-5p [%c] - %m%n

@ -0,0 +1,24 @@
<!--
~ Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
~
~ Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
~
~ Licensed under the Entgra Commercial License, Version 1.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://entgra.io/licenses/entgra-commercial/1.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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="mdm-suite">
</suite>

@ -0,0 +1,37 @@
<!--
~ Copyright (C) 2018 - 2020 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
~
~ Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
~
~ Licensed under the Entgra Commercial License, Version 1.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://entgra.io/licenses/entgra-commercial/1.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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="iot-suite-initializer" verbose="10">
<parameter name="useDefaultListeners" value="false"/>
<listeners>
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestExecutionListener"/>
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestManagerListener"/>
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestReportListener"/>
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestSuiteListener"/>
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestTransformerListener"/>
</listeners>
<test name="iot-test-cases" preserve-order="true" parallel="false">
<classes>
<class name="org.wso2.iot.integration.jmeter.DeviceMgtCoreAPIJmeterTestCase"/>
</classes>
</test>
</suite>

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2018 - 2023 Entgra (Pvt) Ltd, Inc - All Rights Reserved.
~
~ Unauthorised copying/redistribution of this file, via any medium is strictly prohibited.
~
~ Licensed under the Entgra Commercial License, Version 1.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://entgra.io/licenses/entgra-commercial/1.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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>io.entgra.product.community</groupId>
<artifactId>product-parent</artifactId>
<version>5.1.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>integration-test</artifactId>
<packaging>pom</packaging>
<name>Entgra IoT - Integration Tests</name>
<modules>
<module>iot-community</module>
</modules>
</project>

@ -38,6 +38,7 @@
<module>iot-core</module>
<module>p2-profile</module>
<module>distribution</module>
<module>integration-test</module>
</modules>
<dependencyManagement>
@ -101,6 +102,255 @@
<artifactId>entgra-iot-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automation</groupId>
<artifactId>org.wso2.carbon.automation.engine</artifactId>
<version>${platform.integration.utils.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automation</groupId>
<artifactId>org.wso2.carbon.automation.test.utils</artifactId>
<version>${test.framework.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automationutils</groupId>
<artifactId>org.wso2.carbon.integration.common.utils</artifactId>
<version>${test.framework.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automation</groupId>
<artifactId>org.wso2.carbon.automation.extensions</artifactId>
<version>${platform.integration.utils.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.ws.wso2</groupId>
<artifactId>spring.framework</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
<exclusion>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
</exclusion>
<exclusion>
<groupId>com.saucelabs.selenium</groupId>
<artifactId>sauce-ondemand-driver</artifactId>
</exclusion>
<exclusion>
<groupId>com.saucelabs.selenium</groupId>
<artifactId>selenium-client-factory</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</exclusion>
<exclusion>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automationutils</groupId>
<artifactId>org.wso2.carbon.integration.common.extensions</artifactId>
<version>${automation.utils.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ftpserver</groupId>
<artifactId>ftpserver-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-logging-juli</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.ws.wso2</groupId>
<artifactId>spring.framework</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
</exclusion>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
</exclusion>
<exclusion>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.jmeter</groupId>
<artifactId>ApacheJMeter_core</artifactId>
</exclusion>
<exclusion>
<groupId>com.saucelabs.selenium</groupId>
<artifactId>sauce-ondemand-driver</artifactId>
</exclusion>
<exclusion>
<groupId>com.saucelabs.selenium</groupId>
<artifactId>selenium-client-factory</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ws.commons.axiom.wso2</groupId>
<artifactId>axiom</artifactId>
</exclusion>
<exclusion>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.automationutils</groupId>
<artifactId>org.wso2.carbon.integration.common.admin.client</artifactId>
<version>${automation.utils.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.commons</groupId>
<artifactId>org.wso2.carbon.user.mgt.stub</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.commons</groupId>
<artifactId>org.wso2.carbon.ndatasource.stub</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon.commons</groupId>
<artifactId>org.wso2.carbon.authenticator.stub</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${google.gson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -123,6 +373,11 @@
<carbon.device.mgt.plugin.version>6.0.13-SNAPSHOT</carbon.device.mgt.plugin.version>
<!--Testing-->
<google.gson.version>2.8.5</google.gson.version>
<platform.integration.utils.version>4.4.3</platform.integration.utils.version>
<automation.utils.version>4.4.2</automation.utils.version>
<test.framework.version>4.4.2</test.framework.version>
</properties>

Loading…
Cancel
Save