mirror of
https://repository.entgra.net/community/product-iots.git
synced 2025-09-16 23:32:19 +00:00
Adding test cases
This commit is contained in:
parent
3b68271159
commit
fa359b0455
@ -309,10 +309,10 @@ public final class Constants {
|
|||||||
public static final class UserManagement {
|
public static final class UserManagement {
|
||||||
public static final String USER_MANAGEMENT_GROUP = "user-mgt";
|
public static final String USER_MANAGEMENT_GROUP = "user-mgt";
|
||||||
public static final String USER_NAME = "username123";
|
public static final String USER_NAME = "username123";
|
||||||
public static final String USER_ENDPOINT = "/mdm-admin/users";
|
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_PAYLOAD_FILE_NAME = "user-payloads.json";
|
||||||
public static final String USER_RESPONSE_PAYLOAD_FILE_NAME = "user-response-payloads.json";
|
public static final String USER_RESPONSE_PAYLOAD_FILE_NAME = "user-response-payloads.json";
|
||||||
public static final String VIEW_USER_ENDPOINT = "/mdm-admin/users/view";
|
public static final String GET_ROLES_METHOD = "GET_ROLES";
|
||||||
|
|
||||||
private UserManagement() {
|
private UserManagement() {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
|
|||||||
@ -65,6 +65,9 @@ public class IOTServerExtension extends ExecutionListenerExtension {
|
|||||||
String carbonHome = serverManager.startServer("core");
|
String carbonHome = serverManager.startServer("core");
|
||||||
log.info(carbonHome);
|
log.info(carbonHome);
|
||||||
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
|
System.setProperty(ExtensionConstants.CARBON_HOME, carbonHome);
|
||||||
|
|
||||||
|
// Need to give time for the apis to be added to the synapse configurations.
|
||||||
|
Thread.sleep(30000);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
handleException("Fail to start carbon server ", e);
|
handleException("Fail to start carbon server ", e);
|
||||||
|
|||||||
@ -24,13 +24,18 @@ import org.testng.annotations.BeforeClass;
|
|||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.wso2.carbon.automation.engine.context.TestUserMode;
|
import org.wso2.carbon.automation.engine.context.TestUserMode;
|
||||||
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
|
import org.wso2.carbon.automation.test.utils.http.client.HttpResponse;
|
||||||
import org.wso2.iot.integration.common.*;
|
import org.wso2.iot.integration.common.AssertUtil;
|
||||||
|
import org.wso2.iot.integration.common.Constants;
|
||||||
|
import org.wso2.iot.integration.common.OAuthUtil;
|
||||||
|
import org.wso2.iot.integration.common.PayloadGenerator;
|
||||||
|
import org.wso2.iot.integration.common.RestClient;
|
||||||
|
import org.wso2.iot.integration.common.TestBase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains integration tests for user management backend services.
|
* This class contains integration tests for user management backend services.
|
||||||
*/
|
*/
|
||||||
public class UserManagement extends TestBase {
|
public class UserManagement extends TestBase {
|
||||||
|
private String NON_EXISTING_USERNAME = "non_exiting";
|
||||||
private RestClient client;
|
private RestClient client;
|
||||||
|
|
||||||
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
|
@BeforeClass(alwaysRun = true, groups = { Constants.UserManagement.USER_MANAGEMENT_GROUP})
|
||||||
@ -52,11 +57,11 @@ public class UserManagement extends TestBase {
|
|||||||
|
|
||||||
@Test(description = "Test update user.", dependsOnMethods = {"testAddUser"})
|
@Test(description = "Test update user.", dependsOnMethods = {"testAddUser"})
|
||||||
public void testUpdateUser() throws Exception {
|
public void testUpdateUser() throws Exception {
|
||||||
String url = GetURL(Constants.UserManagement.USER_ENDPOINT);
|
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
|
||||||
HttpResponse response = client.put(url,
|
HttpResponse response = client.put(url,
|
||||||
PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_PAYLOAD_FILE_NAME,
|
PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_PAYLOAD_FILE_NAME,
|
||||||
Constants.HTTP_METHOD_PUT).toString());
|
Constants.HTTP_METHOD_PUT).toString());
|
||||||
Assert.assertEquals(HttpStatus.SC_CREATED, response.getResponseCode());
|
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||||
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
||||||
Constants.HTTP_METHOD_PUT).toString(), response.getData().toString(), true);
|
Constants.HTTP_METHOD_PUT).toString(), response.getData().toString(), true);
|
||||||
|
|
||||||
@ -64,25 +69,26 @@ public class UserManagement extends TestBase {
|
|||||||
|
|
||||||
@Test(description = "Test view user.", dependsOnMethods = {"testUpdateUser"})
|
@Test(description = "Test view user.", dependsOnMethods = {"testUpdateUser"})
|
||||||
public void testViewUser() throws Exception {
|
public void testViewUser() throws Exception {
|
||||||
String url = GetURL(Constants.UserManagement.VIEW_USER_ENDPOINT);
|
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
|
||||||
HttpResponse response = client.get(url);
|
HttpResponse response = client.get(url);
|
||||||
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||||
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
||||||
Constants.HTTP_METHOD_GET).toString(), response.getData().toString(), true);
|
Constants.HTTP_METHOD_GET).toString(), response.getData().toString(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test remove user.", dependsOnMethods = {"testViewUser"})
|
@Test(description = "Test getting user roles.", dependsOnMethods = {"testViewUser"})
|
||||||
public void testRemoveUser() throws Exception {
|
public void testGetUserRoles() throws Exception {
|
||||||
String url = GetURL(Constants.UserManagement.USER_ENDPOINT);
|
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME + "/roles";
|
||||||
HttpResponse response = client.delete(url);
|
HttpResponse response = client.get(url);
|
||||||
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||||
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
AssertUtil.jsonPayloadCompare(PayloadGenerator.getJsonPayload(Constants.UserManagement.USER_RESPONSE_PAYLOAD_FILE_NAME,
|
||||||
Constants.HTTP_METHOD_DELETE).toString(), response.getData().toString(), true);
|
Constants.UserManagement.GET_ROLES_METHOD).toString(), response.getData().toString(), true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String GetURL(String endPoint) {
|
@Test(description = "Test remove user.", dependsOnMethods = {"testGetUserRoles"})
|
||||||
return endPoint + "?username=" + Constants.UserManagement.USER_NAME;
|
public void testRemoveUser() throws Exception {
|
||||||
|
String url = Constants.UserManagement.USER_ENDPOINT + "/" + Constants.UserManagement.USER_NAME;
|
||||||
|
HttpResponse response = client.delete(url);
|
||||||
|
Assert.assertEquals(HttpStatus.SC_OK, response.getResponseCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -1,24 +1,24 @@
|
|||||||
{
|
{
|
||||||
"POST": {
|
"POST": {
|
||||||
"statusCode": 201,
|
"username":"PRIMARY/username123",
|
||||||
"messageFromServer": "User by username: PRIMARY/username123 was successfully added."
|
"firstname":"userfirstname",
|
||||||
|
"lastname":"userlastname",
|
||||||
|
"emailAddress":"user123@gmail.com"
|
||||||
},
|
},
|
||||||
"PUT": {
|
"PUT": {
|
||||||
"statusCode": 201,
|
"username":"username123",
|
||||||
"messageFromServer": "User by username: username123 was successfully updated."
|
"firstname":"userfname",
|
||||||
|
"lastname":"userlname",
|
||||||
|
"emailAddress":"user1234@gmail.com"
|
||||||
},
|
},
|
||||||
"GET": {
|
"GET": {
|
||||||
"statusCode": 200,
|
|
||||||
"messageFromServer": "User information was retrieved successfully.",
|
|
||||||
"responseContent": {
|
|
||||||
"username": "username123",
|
"username": "username123",
|
||||||
"firstname": "userfname",
|
"firstname": "userfname",
|
||||||
"lastname": "userlname",
|
"lastname": "userlname",
|
||||||
"emailAddress": "user1234@gmail.com"
|
"emailAddress": "user1234@gmail.com"
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"DELETE": {
|
"GET_ROLES": {
|
||||||
"statusCode": 200,
|
"roles": ["admin"],
|
||||||
"messageFromServer": "User by username: username123 was successfully removed."
|
"count": 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -28,21 +28,21 @@
|
|||||||
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestTransformerListener"/>
|
<listener class-name="org.wso2.carbon.automation.engine.testlisteners.TestTransformerListener"/>
|
||||||
</listeners>
|
</listeners>
|
||||||
|
|
||||||
<test name="mobile-device-mgt-no-devices" preserve-order="true" parallel="false">
|
<!--<test name="mobile-device-mgt-no-devices" preserve-order="true" parallel="false">-->
|
||||||
<classes>
|
<!--<classes>-->
|
||||||
<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagementWithNoDevices"/>
|
<!--<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagementWithNoDevices"/>-->
|
||||||
</classes>
|
<!--</classes>-->
|
||||||
</test>
|
<!--</test>-->
|
||||||
<test name="android-enrollment" preserve-order="true" parallel="false">
|
<!--<test name="android-enrollment" preserve-order="true" parallel="false">-->
|
||||||
<classes>
|
<!--<classes>-->
|
||||||
<class name="org.wso2.iot.integration.device.enrollment.AndroidEnrollment"/>
|
<!--<class name="org.wso2.iot.integration.device.enrollment.AndroidEnrollment"/>-->
|
||||||
</classes>
|
<!--</classes>-->
|
||||||
</test>
|
<!--</test>-->
|
||||||
<test name="android-operation" preserve-order="false" parallel="true">
|
<!--<test name="android-operation" preserve-order="false" parallel="true">-->
|
||||||
<classes>
|
<!--<classes>-->
|
||||||
<class name="org.wso2.iot.integration.device.operation.AndroidOperation"/>
|
<!--<class name="org.wso2.iot.integration.device.operation.AndroidOperation"/>-->
|
||||||
</classes>
|
<!--</classes>-->
|
||||||
</test>
|
<!--</test>-->
|
||||||
<!--<test name="windows-enrollment" preserve-order="true" parallel="false">-->
|
<!--<test name="windows-enrollment" preserve-order="true" parallel="false">-->
|
||||||
<!--<classes>-->
|
<!--<classes>-->
|
||||||
<!--<class name="org.wso2.iot.integration.device.enrollment.WindowsEnrollment"/>-->
|
<!--<class name="org.wso2.iot.integration.device.enrollment.WindowsEnrollment"/>-->
|
||||||
@ -73,11 +73,11 @@
|
|||||||
<!--<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagement"/>-->
|
<!--<class name="org.wso2.iot.integration.mobileDevice.MobileDeviceManagement"/>-->
|
||||||
<!--</classes>-->
|
<!--</classes>-->
|
||||||
<!--</test>-->
|
<!--</test>-->
|
||||||
<!--<test name="user-mgt" preserve-order="true" parallel="false">-->
|
<test name="user-mgt" preserve-order="true" parallel="false">
|
||||||
<!--<classes>-->
|
<classes>
|
||||||
<!--<class name="org.wso2.iot.integration.user.UserManagement"/>-->
|
<class name="org.wso2.iot.integration.user.UserManagement"/>
|
||||||
<!--</classes>-->
|
</classes>
|
||||||
<!--</test>-->
|
</test>
|
||||||
<!--<test name="role-mgt" preserve-order="true" parallel="false">-->
|
<!--<test name="role-mgt" preserve-order="true" parallel="false">-->
|
||||||
<!--<classes>-->
|
<!--<classes>-->
|
||||||
<!--<class name="org.wso2.iot.integration.role.RoleManagement"/>-->
|
<!--<class name="org.wso2.iot.integration.role.RoleManagement"/>-->
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user