mirror of
https://github.com/Alfresco/SearchServices.git
synced 2025-10-01 14:41:19 +00:00
Added createTenant method to use it in dataPreparation of tests and updated dataPreparation accordingly
This commit is contained in:
@@ -2,8 +2,8 @@ package org.alfresco.rest.networks;
|
|||||||
|
|
||||||
import org.alfresco.rest.RestTest;
|
import org.alfresco.rest.RestTest;
|
||||||
import org.alfresco.rest.requests.RestNetworksApi;
|
import org.alfresco.rest.requests.RestNetworksApi;
|
||||||
import org.alfresco.utility.data.UserRole;
|
import org.alfresco.rest.requests.RestTenantApi;
|
||||||
import org.alfresco.utility.exception.DataPreparationException;
|
import org.alfresco.utility.constants.UserRole;
|
||||||
import org.alfresco.utility.model.SiteModel;
|
import org.alfresco.utility.model.SiteModel;
|
||||||
import org.alfresco.utility.model.UserModel;
|
import org.alfresco.utility.model.UserModel;
|
||||||
import org.alfresco.utility.testrail.ExecutionType;
|
import org.alfresco.utility.testrail.ExecutionType;
|
||||||
@@ -16,81 +16,85 @@ import org.testng.annotations.Test;
|
|||||||
/**
|
/**
|
||||||
* Created by Cristina Axinte on 9/26/2016.
|
* Created by Cristina Axinte on 9/26/2016.
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "rest-api", "networks", "sanity" })
|
@Test(groups = { "rest-api", "networks" })
|
||||||
public class RestGetNetworkTest extends RestTest
|
public class RestGetNetworkTest extends RestTest
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
RestNetworksApi networkApi;
|
RestNetworksApi networkApi;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RestTenantApi tenantApi;
|
||||||
|
|
||||||
UserModel adminTenantUser;
|
UserModel adminTenantUser;
|
||||||
UserModel tenantUser;
|
UserModel tenantUser;
|
||||||
UserModel managerTenantUser;
|
UserModel managerTenantUser;
|
||||||
UserModel collaboratorTenantUser;
|
UserModel collaboratorTenantUser;
|
||||||
UserModel consumerTenantUser;
|
UserModel consumerTenantUser;
|
||||||
UserModel contributorTenantUser;
|
UserModel contributorTenantUser;
|
||||||
|
String tenantName;
|
||||||
|
String anotherTenantName;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass(alwaysRun = true)
|
||||||
public void setup() throws DataPreparationException
|
public void dataPreparation() throws Exception
|
||||||
{
|
{
|
||||||
// input data should be created for handle tenants:
|
UserModel adminuser = dataUser.getAdminUser();
|
||||||
// create tenant "tenant1" with password "password"
|
adminTenantUser = UserModel.getAdminTenantUser();
|
||||||
|
tenantName = adminTenantUser.getDomain();
|
||||||
|
|
||||||
// with admin "admin@tenant1" create user "test1@tenant1" with password "password"
|
restClient.authenticateUser(adminuser);
|
||||||
adminTenantUser = new UserModel("admin@tenant1", "password");
|
tenantApi.useRestClient(restClient);
|
||||||
tenantUser = new UserModel("test1@tenant1", "password");
|
tenantApi.createTenant(adminTenantUser.getDomain());
|
||||||
// managerTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1");
|
UserModel adminAnotherTenantUser = UserModel.getAdminTenantUser();
|
||||||
// collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1");
|
anotherTenantName = adminAnotherTenantUser.getDomain();
|
||||||
// consumerTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1");
|
tenantApi.createTenant(anotherTenantName);
|
||||||
// contributorTenantUser = dataUser.usingUser(adminTenantUser).createUser("manTenant2@tenant1");
|
|
||||||
managerTenantUser = new UserModel("manTenant@tenant1", "password");
|
|
||||||
collaboratorTenantUser = new UserModel("colTenant@tenant1", "password");
|
|
||||||
consumerTenantUser = new UserModel("consTenant@tenant1", "password");
|
|
||||||
contributorTenantUser = new UserModel("contTenant@tenant1", "password");
|
|
||||||
|
|
||||||
SiteModel site=dataSite.usingUser(adminTenantUser).createPublicRandomSite();
|
tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant");
|
||||||
|
managerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("manTenant");
|
||||||
|
collaboratorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("colTenant");
|
||||||
|
consumerTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("consTenant");
|
||||||
|
contributorTenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("contTenant");
|
||||||
|
|
||||||
|
SiteModel site = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
|
||||||
dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager);
|
dataUser.usingUser(adminTenantUser).addUserToSite(managerTenantUser, site, UserRole.SiteManager);
|
||||||
dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator);
|
dataUser.usingUser(adminTenantUser).addUserToSite(collaboratorTenantUser, site, UserRole.SiteCollaborator);
|
||||||
dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer);
|
dataUser.usingUser(adminTenantUser).addUserToSite(consumerTenantUser, site, UserRole.SiteConsumer);
|
||||||
dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteConsumer);
|
dataUser.usingUser(adminTenantUser).addUserToSite(contributorTenantUser, site, UserRole.SiteConsumer);
|
||||||
|
|
||||||
|
networkApi.useRestClient(restClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = "sanity")
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status")
|
||||||
public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception
|
public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
UserModel tenantUser = new UserModel("nonexisting", "password");
|
||||||
UserModel tenantUser = new UserModel("nonexisting@tenant1", "password");
|
tenantUser.setDomain(tenantName);
|
||||||
restClient.authenticateUser(tenantUser);
|
restClient.authenticateUser(tenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = "sanity")
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and response is not empty")
|
||||||
public void adminTenantChecksIfNetworkIsPresent() throws Exception
|
public void adminTenantChecksIfNetworkIsPresent() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(adminTenantUser);
|
restClient.authenticateUser(adminTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
networkApi.getNetwork(adminTenantUser.getDomain());
|
||||||
networkApi.getNetwork(tenantName);
|
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets specific network with Rest API and checks response parameters are correct")
|
||||||
public void adminTenantChecksNetworkParamsAreCorrect() throws Exception
|
public void adminTenantChecksNetworkParamsAreCorrect() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(adminTenantUser);
|
restClient.authenticateUser(adminTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true);
|
networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets non exisiting network with Rest API and checks the not found status")
|
||||||
public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception
|
public void adminTenantChecksIfNonExistingNetworkIsNotFound() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "netenant";
|
String tenantName = "notenant";
|
||||||
restClient.authenticateUser(adminTenantUser);
|
restClient.authenticateUser(adminTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString());
|
||||||
}
|
}
|
||||||
@@ -98,19 +102,15 @@ public class RestGetNetworkTest extends RestTest
|
|||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify tenant admin user gets another exisiting network with Rest API and checks the forbidden status")
|
||||||
public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception
|
public void adminTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant2";
|
|
||||||
restClient.authenticateUser(adminTenantUser);
|
restClient.authenticateUser(adminTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
networkApi.getNetwork(anotherTenantName);
|
||||||
networkApi.getNetwork(tenantName);
|
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets its network with Rest API and response is not empty")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets its network with Rest API and response is not empty")
|
||||||
public void userTenantChecksIfNetworkIsPresent() throws Exception
|
public void userTenantChecksIfNetworkIsPresent() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(tenantUser);
|
restClient.authenticateUser(tenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||||
}
|
}
|
||||||
@@ -118,18 +118,15 @@ public class RestGetNetworkTest extends RestTest
|
|||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets specific network with Rest API and checks response parameters are correct")
|
||||||
public void userTenantChecksNetworkParamsAreCorrect() throws Exception
|
public void userTenantChecksNetworkParamsAreCorrect() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(tenantUser);
|
restClient.authenticateUser(tenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true);
|
networkApi.getNetwork(tenantName).assertNetworkHasName(tenantName).assertNetworkIsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets non exisiting network with Rest API and checks the not found status")
|
||||||
public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception
|
public void userTenantChecksIfNonExistingNetworkIsNotFound() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "netenant";
|
String tenantName = "nontenant";
|
||||||
restClient.authenticateUser(tenantUser);
|
restClient.authenticateUser(tenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND.toString());
|
||||||
}
|
}
|
||||||
@@ -137,49 +134,43 @@ public class RestGetNetworkTest extends RestTest
|
|||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify any tenant user gets another exisiting network with Rest API and checks the forbidden status")
|
||||||
public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception
|
public void userTenantChecksIfAnotherExistingNetworkIsForbidden() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant2";
|
|
||||||
restClient.authenticateUser(tenantUser);
|
restClient.authenticateUser(tenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
networkApi.getNetwork(anotherTenantName);
|
||||||
networkApi.getNetwork(tenantName);
|
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = "sanity")
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify manager tenant user gets its network with Rest API and response is not empty")
|
||||||
public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception
|
public void tenantManagerUserChecksIfNetworkIsPresent() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(managerTenantUser);
|
restClient.authenticateUser(managerTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = "sanity")
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify collaborator tenant user gets its network with Rest API and response is not empty")
|
||||||
public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception
|
public void tenantCollaboratorUserChecksIfNetworkIsPresent() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(collaboratorTenantUser);
|
restClient.authenticateUser(collaboratorTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = "sanity")
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify consumer tenant user gets its network with Rest API and response is not empty")
|
||||||
public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception
|
public void tenantConsumerUserChecksIfNetworkIsPresent() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(consumerTenantUser);
|
restClient.authenticateUser(consumerTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(groups = "sanity")
|
||||||
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty")
|
@TestRail(section = { "rest-api", "networks" }, executionType = ExecutionType.SANITY, description = "Verify contributor tenant user gets its network with Rest API and response is not empty")
|
||||||
public void tenantContributorUserChecksIfNetworkIsPresent() throws Exception
|
public void tenantContributorUserChecksIfNetworkIsPresent() throws Exception
|
||||||
{
|
{
|
||||||
String tenantName = "tenant1";
|
|
||||||
restClient.authenticateUser(contributorTenantUser);
|
restClient.authenticateUser(contributorTenantUser);
|
||||||
networkApi.useRestClient(restClient);
|
|
||||||
networkApi.getNetwork(tenantName);
|
networkApi.getNetwork(tenantName);
|
||||||
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK.toString());
|
||||||
}
|
}
|
||||||
|
@@ -8,7 +8,7 @@ admin.user=admin
|
|||||||
admin.password=admin
|
admin.password=admin
|
||||||
|
|
||||||
# rest related
|
# rest related
|
||||||
rest.basePath=alfresco/api/tenant1/public/alfresco/versions/1
|
rest.basePath=alfresco/api/-default-/public/alfresco/versions/1
|
||||||
|
|
||||||
|
|
||||||
# TEST MANAGEMENT SECTION - Test Rail
|
# TEST MANAGEMENT SECTION - Test Rail
|
||||||
|
@@ -3,15 +3,19 @@
|
|||||||
<suite name="REST API DEMO TESTS" parallel="classes">
|
<suite name="REST API DEMO TESTS" parallel="classes">
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>
|
<listener class-name="org.alfresco.utility.report.ReportListenerAdapter"></listener>
|
||||||
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
|
<!-- <listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener> -->
|
||||||
<listener class-name="org.alfresco.utility.report.log.LogsListener"></listener>
|
<listener class-name="org.alfresco.utility.report.log.LogsListener"></listener>
|
||||||
</listeners>
|
</listeners>
|
||||||
<test name="Test">
|
<test name="Rest API Tests">
|
||||||
<classes>
|
<groups>
|
||||||
<class name="org.alfresco.rest.demo.SamplePeopleTest"></class>
|
<run>
|
||||||
<class name="org.alfresco.rest.demo.SampleSitesTest"></class>
|
<include name="sanity" />
|
||||||
<class name="org.alfresco.rest.demo.SampleCommentsTest"></class>
|
</run>
|
||||||
</classes>
|
</groups>
|
||||||
|
<packages>
|
||||||
|
<package name="org.alfresco.rest.demo"></package>
|
||||||
|
<package name="org.alfresco.rest.networks"></package>
|
||||||
|
</packages>
|
||||||
|
|
||||||
</test> <!-- Test -->
|
</test> <!-- Test -->
|
||||||
</suite> <!-- Suite -->
|
</suite> <!-- Suite -->
|
||||||
|
Reference in New Issue
Block a user