From cacc4d4772964f20916d0ae84d6676b7574d581b Mon Sep 17 00:00:00 2001 From: Menaka Jayawardena Date: Wed, 25 Jan 2017 14:18:36 +0530 Subject: [PATCH] Access token generation flow fixed. --- .../tests-common/web-ui-pages/pom.xml | 2 +- .../iot/integration/common/Constants.java | 29 ++-- .../iot/integration/common/IOTHttpClient.java | 38 ++--- .../iot/integration/common/OAuthUtil.java | 10 +- .../integration/common/PayloadGenerator.java | 2 +- .../wso2/iot/integration/common/TestBase.java | 9 +- .../device/enrollment/AndroidEnrollment.java | 19 +-- .../MobileDeviceManagementWithNoDevices.java | 12 +- .../iot/integration/util/ServerRestart.java | 4 + .../src/test/resources/automation.xml | 8 +- .../payloads/android-enrollment-payloads.json | 125 +++++++++++----- .../android-enrollment-response-payloads.json | 18 +-- .../src/test/resources/testng.xml | 140 +++++++++--------- 13 files changed, 231 insertions(+), 185 deletions(-) create mode 100644 modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/util/ServerRestart.java diff --git a/modules/integration/tests-common/web-ui-pages/pom.xml b/modules/integration/tests-common/web-ui-pages/pom.xml index 7dcce232..0dbd7992 100644 --- a/modules/integration/tests-common/web-ui-pages/pom.xml +++ b/modules/integration/tests-common/web-ui-pages/pom.xml @@ -22,7 +22,7 @@ org.wso2.iot tests-common - 3.1.0-SNAPSHOT + 3.0.0-SNAPSHOT ../pom.xml diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/Constants.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/Constants.java index 537c9538..920bd879 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/Constants.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/Constants.java @@ -27,7 +27,7 @@ public final class Constants { public static final String DEVICE_ID = "1234"; public static final String NUMBER_NOT_EQUAL_TO_DEVICE_ID = "1111"; public static final String DEVICE_IMEI = "123123123"; - public static final String AUTOMATION_CONTEXT = "MDM"; + public static final String AUTOMATION_CONTEXT = "IOT"; public static final String APPLICATION_JSON = "application/json"; public static final String APPLICATION_URL_ENCODED = "application/x-www-form-urlencoded"; public static final String OAUTH_CLIENT_ID = "client_id"; @@ -46,16 +46,23 @@ public final class Constants { public static final String ZERO = "0"; public static final String NULL = "[]"; - public static final class DynamicClientAuthentication { - public static final String REGISTRATION_ENDPOINT = "/dynamic-client-web/register"; - public static final String TOKEN_ENDPOINT = "/oauth2/token"; - public static final String OAUTH_TOKEN_PAYLOAD = "grant_type=password&username=admin&password=admin&scope=prod"; + 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 OAUTH_TOKEN_PAYLOAD = "username=admin&password=admin&grant_type=password&scope=perm:android:enroll perm:android:wipe perm:android:ring perm:android:lock-devices perm:android:configure-vpn perm:android:configure-wifi perm:android:enroll perm:android:uninstall-application perm:android:manage-configuration perm:android:location perm:android:install-application perm:android:mute perm:android:change-lock-code perm:android:blacklist-applications perm:android:set-password-policy perm:android:encrypt-storage perm:android:clear-password perm:android:enterprise-wipe perm:android:info perm:android:view-configuration perm:android:upgrade-firmware perm:android:set-webclip perm:android:send-notification perm:android:disenroll perm:android:update-application perm:android:unlock-devices perm:android:control-camera perm:android:reboot perm:android:logcat appm:subscribe perm:sign-csr perm:admin:devices:view perm:roles:add perm:roles:add-users perm:roles:update perm:roles:permissions perm:roles:details perm:roles:view perm:roles:create-combined-role perm:roles:delete perm:dashboard:vulnerabilities perm:dashboard:non-compliant-count perm:dashboard:non-compliant perm:dashboard:by-groups perm:dashboard:device-counts perm:dashboard:feature-non-compliant perm:dashboard:count-overview perm:dashboard:filtered-count perm:dashboard:details perm:get-activity perm:devices:delete perm:devices:applications perm:devices:effective-policy perm:devices:compliance-data perm:devices:features perm:devices:operations perm:devices:search perm:devices:details perm:devices:update perm:devices:view perm:view-configuration perm:manage-configuration perm:policies:remove perm:policies:priorities perm:policies:deactivate perm:policies:get-policy-details perm:policies:manage perm:policies:activate perm:policies:update perm:policies:changes perm:policies:get-details perm:users:add perm:users:details perm:users:count perm:users:delete perm:users:roles perm:users:user-details perm:users:credentials perm:users:search perm:users:is-exist perm:users:update perm:users:send-invitation perm:admin-users:view perm:groups:devices perm:groups:update perm:groups:add perm:groups:device perm:groups:devices-count perm:groups:remove perm:groups:groups perm:groups:groups-view perm:groups:share perm:groups:count perm:groups:roles perm:groups:devices-remove perm:groups:devices-add perm:groups:assign perm:device-types:features perm:device-types:types perm:applications:install perm:applications:uninstall perm:admin-groups:count perm:admin-groups:view perm:notifications:mark-checked perm:notifications:view perm:admin:certificates:delete perm:admin:certificates:details perm:admin:certificates:view perm:admin:certificates:add perm:admin:certificates:verify perm:ios:enroll perm:ios:view-device perm:ios:apn perm:ios:ldap perm:ios:enterprise-app perm:ios:store-application perm:ios:remove-application perm:ios:app-list perm:ios:profile-list perm:ios:lock perm:ios:enterprise-wipe perm:ios:device-info perm:ios:restriction perm:ios:email perm:ios:cellular perm:ios:applications perm:ios:wifi perm:ios:ring perm:ios:location perm:ios:notification perm:ios:airplay perm:ios:caldav perm:ios:cal-subscription perm:ios:passcode-policy perm:ios:webclip perm:ios:vpn perm:ios:per-app-vpn perm:ios:app-to-per-app-vpn perm:ios:app-lock perm:ios:clear-passcode perm:ios:remove-profile perm:ios:get-restrictions perm:ios:wipe-data perm:admin"; private static StringBuffer dynamicClientPayloadBuffer = new StringBuffer(); - public static final String DYNAMIC_CLIENT_REGISTRATION_PAYLOAD = dynamicClientPayloadBuffer.append("{\"clientName\":"). - append(" \"device\",\"owner\": \"admin\",\"grantType\": \"password\",\"callbackUrl\": \"www.google.lk\"," + - "\"saasApp\": \"" + true + "\"}").toString(); + public static final String API_APP_REGISTRATION_PAYLOAD = dynamicClientPayloadBuffer.append("{ \n" + + " \"applicationName\":\"app_12345\",\n" + " \"isAllowedToAllDomains\":false,\n" + + " \"tags\":[\"android\", \"device_management\"],\n" + " \"isMappingAnExistingOAuthApp\":false\n" + + "}").toString(); - private DynamicClientAuthentication() { + private APIApplicationRegistration() { throw new AssertionError(); } } @@ -63,7 +70,7 @@ public final class Constants { 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 = "/mdm-android-agent/enrollment/"; + public static final String ENROLLMENT_ENDPOINT = "/api/device-mgt/android/v1.0/devices"; public static final String ENROLLMENT_GROUP = "android-enrollment"; private AndroidEnrollment() { @@ -189,7 +196,7 @@ public final class Constants { public static final class MobileDeviceManagement { public static final String MOBILE_DEVICE_MANAGEMENT_GROUP = "mobile-device-mgt"; - public static final String GET_DEVICE_COUNT_ENDPOINT = "/mdm-admin/devices/count"; + public static final String GET_DEVICE_COUNT_ENDPOINT = "/api/device-mgt/v1.0/devices"; public static final String NO_OF_DEVICES = "1"; public static final String GET_ALL_DEVICES_ENDPOINT = "/mdm-admin/devices"; public static final String VIEW_DEVICE_TYPES_ENDPOINT = "/mdm-admin/devices/types"; diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/IOTHttpClient.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/IOTHttpClient.java index 404175e6..76ec1137 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/IOTHttpClient.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/IOTHttpClient.java @@ -41,7 +41,7 @@ public class IOTHttpClient { private static final String AUTHORIZATION = "Authorization"; private static Log log = LogFactory.getLog(IOTHttpClient.class); private String backEndUrl; - private String authrizationString; + private String authorizationString; private Map requestHeaders = new HashMap(); public IOTHttpClient(String backEndUrl, String contentType, String authorization) { @@ -49,17 +49,17 @@ public class IOTHttpClient { this.backEndUrl = backEndUrl; this.requestHeaders.put(Constants.CONTENT_TYPE, contentType); if (authorization != null || !authorization.isEmpty()) { - this.authrizationString = authorization; + this.authorizationString = authorization; this.requestHeaders.put(AUTHORIZATION, authorization); } } - public String getAuthrizationString() { - return authrizationString; + public String getAuthorizationString() { + return authorizationString; } - public void setAuthrizationString(String authrizationString) { - this.authrizationString = authrizationString; + public void setAuthorizationString(String authorizationString) { + this.authorizationString = authorizationString; } public void setHttpHeader(String headerName, String value) { @@ -78,11 +78,11 @@ public class IOTHttpClient { HttpClient client = new HttpClient(); try { ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory(); - Protocol https = new Protocol("https", socketFactory, 9443); - Protocol.registerProtocol("https", https); + 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, authrizationString); + method.setRequestHeader(AUTHORIZATION, authorizationString); StringRequestEntity requestEntity = new StringRequestEntity(body, requestHeaders.get(Constants.CONTENT_TYPE), Constants.UTF8); method.setRequestEntity(requestEntity); @@ -94,7 +94,7 @@ public class IOTHttpClient { } catch (GeneralSecurityException e) { log.error("Failure occurred at IOTResponse post for GeneralSecurityException", e); } catch (IOException e) { - log.error("Failure occured at IOTResponse post for IOException", e); + log.error("Failure occurred at IOTResponse post for IOException", e); } return null; } @@ -103,11 +103,11 @@ public class IOTHttpClient { HttpClient client = new HttpClient(); try { ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory(); - Protocol https = new Protocol("https", socketFactory, 9443); - Protocol.registerProtocol("https", https); + 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, authrizationString); + method.setRequestHeader(AUTHORIZATION, authorizationString); StringRequestEntity requestEntity = new StringRequestEntity( body, requestHeaders.get(Constants.CONTENT_TYPE), Constants.UTF8); method.setRequestEntity(requestEntity); @@ -129,11 +129,11 @@ public class IOTHttpClient { try { ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory(); - Protocol https = new Protocol("https", socketFactory, 9443); - Protocol.registerProtocol("https", https); + 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, authrizationString); + method.setRequestHeader(AUTHORIZATION, authorizationString); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); IOTResponse iotResponse = new IOTResponse(); @@ -157,13 +157,13 @@ public class IOTHttpClient { try { ProtocolSocketFactory socketFactory = new EasySSLProtocolSocketFactory(); - Protocol https = new Protocol("https", socketFactory, 9443); - Protocol.registerProtocol("https", https); + 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, authrizationString); + method.setRequestHeader(AUTHORIZATION, authorizationString); method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false)); diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/OAuthUtil.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/OAuthUtil.java index bfa54cdb..dc93dedf 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/OAuthUtil.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/OAuthUtil.java @@ -30,8 +30,9 @@ public class OAuthUtil { public static String getOAuthToken(String backendHTTPURL, String backendHTTPSURL) throws Exception { RestClient client = new RestClient(backendHTTPURL, Constants.APPLICATION_JSON); - HttpResponse oAuthData = client.post(Constants.DynamicClientAuthentication.REGISTRATION_ENDPOINT, - Constants.DynamicClientAuthentication.DYNAMIC_CLIENT_REGISTRATION_PAYLOAD); + client.setHttpHeader("Authorization", "Basic YWRtaW46YWRtaW4="); + 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(); @@ -39,8 +40,9 @@ public class OAuthUtil { 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.DynamicClientAuthentication.TOKEN_ENDPOINT, - Constants.DynamicClientAuthentication.OAUTH_TOKEN_PAYLOAD); + oAuthData = client.post(Constants.APIApplicationRegistration.TOKEN_ENDPOINT, + Constants.APIApplicationRegistration.OAUTH_TOKEN_PAYLOAD); + System.out.println(oAuthData.getData()); jsonObj = new JSONObject(oAuthData.getData()); return jsonObj.get(Constants.OAUTH_ACCESS_TOKEN).toString(); } diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/PayloadGenerator.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/PayloadGenerator.java index 74c26f46..c7c82e59 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/PayloadGenerator.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/PayloadGenerator.java @@ -35,7 +35,7 @@ public class PayloadGenerator { public static JsonObject getJsonPayload(String fileName, String method) throws FileNotFoundException { - URL url = Thread.currentThread().getContextClassLoader().getResource(PAYLOAD_LOCATION + fileName); + URL url = PayloadGenerator.class.getClassLoader().getResource(PAYLOAD_LOCATION + fileName); JsonObject jsonObject = parser.parse(new FileReader(url.getPath())).getAsJsonObject(); return jsonObject.get(method).getAsJsonObject(); } diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/TestBase.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/TestBase.java index 6883e190..33c9d2bb 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/TestBase.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/common/TestBase.java @@ -19,6 +19,7 @@ package org.wso2.iot.integration.common; import org.wso2.carbon.automation.engine.context.AutomationContext; import org.wso2.carbon.automation.engine.context.TestUserMode; +import org.wso2.carbon.automation.engine.frameworkutils.CodeCoverageUtils; import org.wso2.carbon.automation.engine.frameworkutils.FrameworkPathUtil; import org.wso2.carbon.integration.common.utils.LoginLogoutClient; @@ -35,8 +36,10 @@ public class TestBase { protected void init(TestUserMode userMode) throws Exception { automationContext = new AutomationContext(Constants.AUTOMATION_CONTEXT, userMode); - backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps(); - backendHTTPURL = automationContext.getContextUrls().getWebAppURL(); + backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants + .HTTPS_GATEWAY_PORT)); + backendHTTPURL = automationContext.getContextUrls().getWebAppURL().replace("9763", String.valueOf(Constants + .HTTP_GATEWAY_PORT)); } protected void initPublisher(String productGroupName, String instanceName, @@ -55,7 +58,7 @@ public class TestBase { } protected String getBackendHTTPSURL() throws XPathExpressionException { - return automationContext.getContextUrls().getBackEndUrl(); + return backendHTTPSURL; } protected String getSessionCookie() throws Exception { diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidEnrollment.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidEnrollment.java index b2205cee..cf806cea 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidEnrollment.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/device/enrollment/AndroidEnrollment.java @@ -42,15 +42,12 @@ public class AndroidEnrollment extends TestBase { @Test(description = "Test an Android device enrollment.") public void testEnrollment() throws Exception { - JsonObject enrollmentData = PayloadGenerator.getJsonPayload( - Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_POST); - enrollmentData.addProperty(Constants.DEVICE_IDENTIFIER_KEY, Constants.DEVICE_ID); - HttpResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData.toString()); + String enrollmentData = PayloadGenerator.getJsonPayloadToString(Constants.AndroidEnrollment + .ENROLLMENT_PAYLOAD_FILE_NAME); + HttpResponse response = client.post(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT, enrollmentData); Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); - AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( - Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_POST).toString(), response.getData().toString(), true); + AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayloadToString( + Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME), response.getData(), true); } @Test(description = "Test an Android device is enrolled.", dependsOnMethods = {"testEnrollment"}) @@ -59,7 +56,7 @@ public class AndroidEnrollment extends TestBase { Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode()); AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_GET).toString(), response.getData().toString(), true); + Constants.HTTP_METHOD_GET).toString(), response.getData(), true); } @Test(description = "Test modify enrollment.", dependsOnMethods = {"testIsEnrolled"}) @@ -72,7 +69,7 @@ public class AndroidEnrollment extends TestBase { enrollmentData.toString()); AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, - Constants.HTTP_METHOD_PUT).toString(), response.getData().toString(), true); + Constants.HTTP_METHOD_PUT).toString(), response.getData(), true); } @Test(description = "Test disenrollment.", dependsOnMethods = {"testModifyEnrollment"}) @@ -82,6 +79,6 @@ public class AndroidEnrollment extends TestBase { AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload( Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_DELETE).toString(), - response.getData().toString(), true); + response.getData(), true); } } diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/mobileDevice/MobileDeviceManagementWithNoDevices.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/mobileDevice/MobileDeviceManagementWithNoDevices.java index 2f32fe27..d29a3a08 100644 --- a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/mobileDevice/MobileDeviceManagementWithNoDevices.java +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/mobileDevice/MobileDeviceManagementWithNoDevices.java @@ -45,11 +45,11 @@ public class MobileDeviceManagementWithNoDevices extends TestBase { Assert.assertEquals(Constants.ZERO, response.getBody()); } - @Test(description = "Test view devices with no added devices") - public void testViewDevicesWithNoDevices() throws Exception { - IOTResponse response = client.get(Constants.MobileDeviceManagement.GET_ALL_DEVICES_ENDPOINT); - Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); - Assert.assertEquals(response.getBody(), Constants.NULL); - } +// @Test(description = "Test view devices with no added devices") +// public void testViewDevicesWithNoDevices() throws Exception { +// IOTResponse response = client.get(Constants.MobileDeviceManagement.GET_ALL_DEVICES_ENDPOINT); +// Assert.assertEquals(HttpStatus.SC_OK, response.getStatus()); +// Assert.assertEquals(response.getBody(), Constants.NULL); +// } } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/util/ServerRestart.java b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/util/ServerRestart.java new file mode 100644 index 00000000..ea5967d5 --- /dev/null +++ b/modules/integration/tests-integration/src/test/java/org/wso2/iot/integration/util/ServerRestart.java @@ -0,0 +1,4 @@ +package org.wso2.iot.integration.util; + +public class ServerRestart { +} diff --git a/modules/integration/tests-integration/src/test/resources/automation.xml b/modules/integration/tests-integration/src/test/resources/automation.xml index 09c68d76..b538772d 100644 --- a/modules/integration/tests-integration/src/test/resources/automation.xml +++ b/modules/integration/tests-integration/src/test/resources/automation.xml @@ -172,9 +172,9 @@ 9763 - 9446 + 9443 - 9445 + @@ -189,9 +189,9 @@ - org.wso2.iot.integration.extensions.BrokerServerExtension + org.wso2.iot.integration.extensions.IOTServerExtension - org.wso2.iot.integration.extensions.AnalyticsServerExtension + org.wso2.carbon.integration.common.extensions.usermgt.UserPopulateExtension diff --git a/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-payloads.json index 6fc027a8..f246be2f 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-payloads.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-payloads.json @@ -1,45 +1,92 @@ { - "POST": { - "name": "milan", - "type": "android", - "description": "milan123", - "deviceIdentifier": "1234", - "enrolmentInfo": { - "ownership": "BYOD", - "status": "ACTIVE", - "owner": "admin" + "id": 101234, + "name": "androiddevice1234", + "type": "android", + "description": "this is an android device", + "deviceIdentifier": "d24f870f390352a41234", + "enrolmentInfo": { + "id": 101234, + "device": { }, - "properties": [ - { - "name": "IMEI", - "value": "123123123" - }, - { - "name": "IMSI", - "value": "123123123" - } - ] + "dateOfEnrolment": 0, + "dateOfLastUpdate": 0, + "ownership": "BYOD", + "status": "CREATED", + "owner": "admin" }, - "PUT": { - "name": "milan123", - "type": "android", - "description": "updatedDescription", - "deviceIdentifier": "1234", - "enrolmentInfo": { - "ownership": "BYOD", - "status": "ACTIVE", - "owner": "admin", - "dateOfEnrolment": "1445438864650" + "features": [ + { + "id": 10, + "code": "aaaa1111", + "name": "newfeature1", + "description": "this is the new feature 1", + "deviceType": "android", + "metadataEntries": [ + { + "id": 10, + "value": { + } + } + ] + } + ], + "properties": [ + { + "name": "property1", + "value": "value1" + } + ], + "deviceInfo": { + "deviceModel": "S8", + "vendor": "SAMSUNG", + "osVersion": "5.1", + "batteryLevel": 1, + "internalTotalMemory": 32, + "internalAvailableMemory": 24, + "externalTotalMemory": 64, + "externalAvailableMemory": 60, + "operator": "dialog", + "connectionType": "GSM", + "mobileSignalStrength": 1, + "ssid": "picassowifi", + "cpuUsage": 0, + "totalRAMMemory": 2, + "availableRAMMemory": 1, + "pluggedIn": false, + "location": { + "deviceId": 0, + "deviceIdentifier": { + "id": "string", + "type": "string" + }, + "latitude": 0, + "longitude": 0, + "street1": "string", + "street2": "string", + "city": "string", + "state": "string", + "zip": "string", + "country": "string" }, - "properties": [ - { - "name": "IMEI", - "value": "123123123" + "deviceDetailsMap": { + }, + "imei": "string", + "imsi": "string" + }, + "applications": [ + { + "id": 0, + "platform": "string", + "category": "string", + "name": "string", + "locationUrl": "string", + "imageUrl": "string", + "version": "string", + "type": "string", + "appProperties": { }, - { - "name": "IMSI", - "value": "123123123" - } - ] - } + "applicationIdentifier": "string", + "memoryUsage": 0 + } + ] } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-response-payloads.json b/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-response-payloads.json index 2e0c38d1..dd51c631 100644 --- a/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-response-payloads.json +++ b/modules/integration/tests-integration/src/test/resources/payloads/android-enrollment-response-payloads.json @@ -1,18 +1,4 @@ { - "POST": { - "responseCode": "Created", - "responseMessage": "Device enrollment succeeded." - }, - "PUT": { - "responseCode": "Accepted", - "responseMessage": "Device enrollment has updated successfully" - }, - "GET": { - "responseCode": "Accepted", - "responseMessage": "Device has already enrolled" - }, - "DELETE": { - "responseCode": "Accepted", - "responseMessage": "Device has removed successfully" - } + "responseCode": "OK", + "responseMessage": "Android device, which carries the id \u0027d24f870f390352a41\u0027 has successfully been enrolled" } \ No newline at end of file diff --git a/modules/integration/tests-integration/src/test/resources/testng.xml b/modules/integration/tests-integration/src/test/resources/testng.xml index 41878cf0..cb4780ba 100644 --- a/modules/integration/tests-integration/src/test/resources/testng.xml +++ b/modules/integration/tests-integration/src/test/resources/testng.xml @@ -39,74 +39,74 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file