Search in sources :

Example 16 with HTTPResponse

use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.

the class NotificationManagement method testAddNotification.

@Test(description = "Test add notification.")
public void testAddNotification() throws Exception {
    HttpResponse response = client.post(Constants.NotificationManagement.NOTIFICATION_ENDPOINT, PayloadGenerator.getJsonPayload(Constants.NotificationManagement.NOTIFICATION_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString());
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.NotificationManagement.NOTIFICATION_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_POST).toString(), response.getData().toString(), true);
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) BeforeTest(org.testng.annotations.BeforeTest) Test(org.testng.annotations.Test)

Example 17 with HTTPResponse

use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.

the class MobileQSGTestCase method testPolicyCreation.

@Test(description = "This test case tests the policy creation through qsg script", dependsOnMethods = { "executeQSGScript" })
public void testPolicyCreation() throws Exception {
    HttpResponse response = client.get(Constants.PolicyManagement.VIEW_POLICY_LIST_ENDPOINT + "?offset=0&limit=10");
    Assert.assertEquals(response.getResponseCode(), HttpStatus.SC_OK);
    Assert.assertTrue(response.getData().contains("android-passcode-policy1"), "Android pass-code policy is not " + "added from qsg script");
    Assert.assertTrue(response.getData().contains("windows-passcode-policy1"), "Windows pass-code policy is not " + "added from qsg script");
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Example 18 with HTTPResponse

use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.

the class UserManagement method testViewUser.

@Test(description = "Test view user.", dependsOnMethods = { "testUpdateUser" })
public void testViewUser() throws Exception {
    String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
    HttpResponse response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME, Constants.HTTP_METHOD_GET).toString(), response.getData(), true);
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Example 19 with HTTPResponse

use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.

the class UserManagement method testIsUserExist.

@Test(description = "Test the API that checks whether user exist.", dependsOnMethods = { "testGetUserRoles" })
public void testIsUserExist() throws Exception {
    String url = Constants.UserManagement.USER_ENDPOINT + "/checkUser?username=" + Constants.UserManagement.USER_NAME;
    HttpResponse response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    Assert.assertEquals("CheckUser API return false even the user with the username " + Constants.UserManagement.USER_NAME + "exists", true, Boolean.parseBoolean(response.getData()));
    url = Constants.UserManagement.USER_ENDPOINT + "/checkUser?username=" + NON_EXISTING_USERNAME;
    response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    Assert.assertEquals("CheckUser API return true but user with " + NON_EXISTING_USERNAME + "exists", false, Boolean.parseBoolean(response.getData()));
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Example 20 with HTTPResponse

use of org.wso2.mdm.qsg.dto.HTTPResponse in project product-iots by wso2.

the class UserManagement method testGetUserRoles.

@Test(description = "Test getting user roles.", dependsOnMethods = { "testViewUser" })
public void testGetUserRoles() throws Exception {
    String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME + "/roles";
    HttpResponse response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
    AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME, Constants.UserManagement.GET_ROLES_METHOD).toString(), response.getData(), true);
    url = Constants.UserManagement.USER_ENDPOINT + "/" + NON_EXISTING_USERNAME + "/roles";
    response = client.get(url);
    Assert.assertEquals(HttpStatus.SC_NOT_FOUND, response.getResponseCode());
}
Also used : HttpResponse(org.wso2.carbon.automation.test.utils.http.client.HttpResponse) Test(org.testng.annotations.Test)

Aggregations

HttpResponse (org.wso2.carbon.automation.test.utils.http.client.HttpResponse)75 Test (org.testng.annotations.Test)72 JsonObject (com.google.gson.JsonObject)15 HTTPResponse (org.wso2.mdm.qsg.dto.HTTPResponse)15 JsonParser (com.google.gson.JsonParser)14 JSONObject (org.json.simple.JSONObject)11 HashMap (java.util.HashMap)9 JsonArray (com.google.gson.JsonArray)8 IOException (java.io.IOException)8 HttpURLConnection (java.net.HttpURLConnection)8 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)7 KeyManagementException (java.security.KeyManagementException)6 KeyStoreException (java.security.KeyStoreException)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 HttpResponse (org.apache.http.HttpResponse)6 ClientProtocolException (org.apache.http.client.ClientProtocolException)6 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)6 HttpPost (org.apache.http.client.methods.HttpPost)5 JSONArray (org.json.simple.JSONArray)5 JsonElement (com.google.gson.JsonElement)4