use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidSenseEnrollment method testEnrollment.
@Test(description = "Test an Android sense device enrollment.")
public void testEnrollment() throws Exception {
// Time for deploying the carbon apps
Thread.sleep(30000);
HttpResponse response = client.post(Constants.AndroidSenseEnrollment.ENROLLMENT_ENDPOINT + DEVICE_ID + "/register?deviceName=android_sense_test", "");
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
JsonElement jsonElement = new JsonParser().parse(response.getData());
JsonObject expectedPayloadObject = jsonElement.getAsJsonObject();
Assert.assertNotNull("Mqtt end-point is returned with the android sense enrollment " + "payload", expectedPayloadObject.get("mqttEndpoint"));
Assert.assertNotNull("Tenant domain is returned with the android sense enrollment " + "payload", expectedPayloadObject.get("tenantDomain"));
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidSenseEnrollment method initTest.
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP })
public void initTest() throws Exception {
super.init(userMode);
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
String auth_string = "Basic " + encoded;
String anaytics_https_url = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants.HTTPS_ANALYTICS_PORT)).replace("/t/" + automationContext.getContextTenant().getDomain(), "") + "/";
this.client = new RestClient(backendHTTPSURL, Constants.APPLICATION_JSON, accessTokenString);
this.analyticsClient = new RestClient(anaytics_https_url, Constants.APPLICATION_JSON, auth_string);
if (this.userMode == TestUserMode.TENANT_ADMIN) {
HttpResponse response = client.post(Constants.AndroidSenseEnrollment.ANALYTICS_ARTIFACTS_DEPLOYMENT_ENDPOINT, "");
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
}
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class ConfigurationManagement method testSaveConfiguration.
@Test(description = "Test save configuration.")
public void testSaveConfiguration() throws Exception {
HttpResponse response = client.post(Constants.ConfigurationManagement.CONFIGURATION_ENDPOINT, PayloadGenerator.getJsonPayload(Constants.ConfigurationManagement.CONFIGURATION_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString());
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.ConfigurationManagement.CONFIGURATION_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString(), response.getData().toString(), true);
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidEnrollment method testIsEnrolled.
@Test(description = "Test an Android device is enrolled.", dependsOnMethods = { "testEnrollment" })
public void testIsEnrolled() throws Exception {
HttpResponse response = client.get(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/status");
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.AndroidEnrollment.ENROLLMENT_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_GET).toString(), response.getData(), true);
}
use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.
the class AndroidEnrollment method testUpdateApplications.
@Test(description = "Test update applications", dependsOnMethods = { "testModifyEnrollment" })
public void testUpdateApplications() throws Exception {
JsonArray updateApplicationData = PayloadGenerator.getJsonArray(Constants.AndroidEnrollment.ENROLLMENT_PAYLOAD_FILE_NAME, Constants.AndroidEnrollment.UPDATE_APPLICATION_METHOD);
HttpResponse response = client.put(Constants.AndroidEnrollment.ENROLLMENT_ENDPOINT + "/" + deviceId + "/applications", updateApplicationData.toString());
Assert.assertEquals("Update of applications for the device id " + deviceId + " failed", HttpStatus.SC_ACCEPTED, response.getResponseCode());
response = client.get(Constants.MobileDeviceManagement.CHANGE_DEVICE_STATUS_ENDPOINT + Constants.AndroidEnrollment.ANDROID_DEVICE_TYPE + "/" + deviceId + "/applications");
Assert.assertEquals("Error while getting application list for the device with the id " + deviceId + " failed", HttpStatus.SC_OK, response.getResponseCode());
JsonArray jsonArray = new JsonParser().parse(response.getData()).getAsJsonArray();
Assert.assertEquals("Installed applications for the device with the device id " + deviceId + " has not been " + "updated yet", 3, jsonArray.size());
}
Aggregations