mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
Merge branch 'master-getNetworkForPerson' into 'master'
Master get network for person See merge request !364
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package org.alfresco.rest.networks;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestNetworkModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests for /people/{personId}/networks
|
||||
*/
|
||||
public class RestGetNetworkForPersonCoreTests extends RestTest
|
||||
{
|
||||
UserModel adminUser;
|
||||
UserModel adminTenantUser;
|
||||
UserModel tenantUser;
|
||||
UserModel randomTestUser;
|
||||
RestNetworkModel restNetworkModel;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
adminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUser);
|
||||
restClient.usingTenant().createTenant(adminTenantUser);
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
|
||||
randomTestUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("randomTestUser");
|
||||
}
|
||||
|
||||
@Bug(id = "needs to be checked")
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify getNetwork request status code is 200 if a user tries to get network information of another user")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE })
|
||||
public void verifyGetNetworkByAUserForAnotherUser() throws Exception
|
||||
{
|
||||
restNetworkModel = restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(randomTestUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restNetworkModel.assertThat().field("id").is(tenantUser.getDomain());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that getNetwork status code is 404 for a personId that does not exist")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE })
|
||||
public void verifyThatGetNetworkStatusIs404ForAPersonIdThatDoesNotExist() throws Exception
|
||||
{
|
||||
UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("validUsername");
|
||||
invalidUser.setUsername("invalidUsername");
|
||||
|
||||
restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername()))
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that getNetwork status code is 404 for a networkId that does not exist")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE })
|
||||
public void verifyThatGetNetworkStatusIs404ForANetworkIdThatDoesNotExist() throws Exception
|
||||
{
|
||||
UserModel invalidUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("invalidNetworkId");
|
||||
invalidUser.setDomain("invalidNetworkId");
|
||||
|
||||
restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(invalidUser).getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidUser.getUsername()))
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify getNetwork request that is made using -me- instead of personId")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.CORE })
|
||||
public void verifyGetNetworkRequestUsingMeInsteadOfPersonId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.alfresco.rest.networks;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestNetworkModel;
|
||||
import org.alfresco.rest.model.RestNetworkQuotaModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Tests for /people/{personId}/networks
|
||||
*/
|
||||
public class RestGetNetworkForPersonFullTests extends RestTest
|
||||
{
|
||||
UserModel adminUser;
|
||||
UserModel adminTenantUser;
|
||||
UserModel secondAdminTenantUser;
|
||||
UserModel tenantUser;
|
||||
RestNetworkModel restNetworkModel;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUser = dataUser.getAdminUser();
|
||||
adminTenantUser = UserModel.getAdminTenantUser();
|
||||
secondAdminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser);
|
||||
restClient.usingTenant().createTenant(secondAdminTenantUser);
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify getNetwork request response entry details")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL })
|
||||
public void verifyGetNetworkRequestResponseEntryDetails() throws Exception
|
||||
{
|
||||
restNetworkModel = restClient.authenticateUser(adminTenantUser).withCoreAPI().usingMe().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restNetworkModel.assertThat().field("quotas").is(new ArrayList<RestNetworkQuotaModel>())
|
||||
.assertThat().field("isEnabled").is("true")
|
||||
.assertThat().field("homeNetwork").is("true")
|
||||
.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that properties parameter is applied to getNetwork request")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL })
|
||||
public void verifyPropertiesParameterIsAppliedToGetNetworkRequest() throws Exception
|
||||
{
|
||||
restNetworkModel = restClient.authenticateUser(adminTenantUser).withParams("properties=id").withCoreAPI().usingMe().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
restNetworkModel.assertThat().field("id").is(adminTenantUser.getDomain().toLowerCase());
|
||||
// TODO add assert that entry has only 1 field
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify getNetwork request status code is 404 for a network to which user does not belong")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.FULL })
|
||||
public void verifyGetNetworkRequestStatusCodeIs404ForANetworkToWhichTheUserDoesNotBelong() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondAdminTenantUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.alfresco.rest.networks;
|
||||
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
@@ -10,11 +12,19 @@ import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests for /people/{personId}/networks
|
||||
*/
|
||||
public class RestGetNetworkForPersonSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
UserModel adminUserModel;
|
||||
UserModel adminTenantUser;
|
||||
UserModel tenantUser;
|
||||
UserModel tenantSiteManager;
|
||||
UserModel tenantSiteCollaborator;
|
||||
UserModel tenantSiteContributor;
|
||||
UserModel tenantSiteConsumer;
|
||||
SiteModel tenantSite;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
@@ -24,51 +34,92 @@ public class RestGetNetworkForPersonSanityTests extends RestTest
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
restClient.usingTenant().createTenant(adminTenantUser);
|
||||
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
|
||||
tenantSiteManager = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteManager");
|
||||
tenantSiteCollaborator = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteCollaborator");
|
||||
tenantSiteContributor = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteContributor");
|
||||
tenantSiteConsumer = dataUser.usingUser(adminTenantUser).createUserWithTenant("tenantSiteConsumer");
|
||||
tenantSite = dataSite.usingUser(tenantSiteManager).createPublicRandomSite();
|
||||
dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteCollaborator, tenantSite, UserRole.SiteCollaborator);
|
||||
dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteContributor, tenantSite, UserRole.SiteContributor);
|
||||
dataUser.usingUser(tenantSiteManager).addUserToSite(tenantSiteConsumer, tenantSite, UserRole.SiteConsumer);
|
||||
}
|
||||
|
||||
@Bug(id = "MNT-16904")
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify non existing user gets another exisiting network with Rest API and checks the forbidden status")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
description = "Verify non existing user gets another existing network with Rest API and checks the forbidden status")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception
|
||||
{
|
||||
UserModel tenantUser = new UserModel("nonexisting", "password");
|
||||
tenantUser.setDomain(adminTenantUser.getDomain());
|
||||
restClient.authenticateUser(tenantUser);
|
||||
restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser);
|
||||
restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify tenant admin user gets specific network with Rest API and response is not empty")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS,TestGroup.SANITY })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void adminTenantChecksIfNetworkIsPresent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminTenantUser);
|
||||
restClient.withCoreAPI().usingUser(adminTenantUser).getNetwork();
|
||||
restClient.authenticateUser(adminTenantUser).withCoreAPI().usingUser(adminTenantUser).getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Bug(id = "needs to be checked")
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify tenant user check network of admin user with Rest API")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(tenantUser).withCoreAPI().usingAuthUser().getNetwork(adminTenantUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify tenant user is not authorized to check network of admin user with Rest API and checks the forbidden status")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(tenantUser);
|
||||
restClient.withCoreAPI().usingAuthUser().getNetwork(adminTenantUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify admin tenant user is not authorized to check network of another user with Rest API and checks the forbidden status")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.COMMENTS, TestGroup.SANITY })
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception
|
||||
{
|
||||
UserModel secondAdminTenantUser = UserModel.getAdminTenantUser();
|
||||
restClient.usingTenant().createTenant(secondAdminTenantUser);
|
||||
UserModel secondTenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant");
|
||||
restClient.authenticateUser(adminTenantUser);
|
||||
restClient.withCoreAPI().usingAuthUser().getNetwork(secondTenantUser);
|
||||
restClient.authenticateUser(adminTenantUser).withCoreAPI().usingAuthUser().getNetwork(secondTenantUser);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify site manager user gets specific network with Rest API and response is not empty")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void siteManagerChecksIfNetworkIsPresent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(tenantSiteManager).withCoreAPI().usingAuthUser().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify site collaborator user gets specific network with Rest API and response is not empty")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void siteCollaboratorChecksIfNetworkIsPresent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(tenantSiteCollaborator).withCoreAPI().usingAuthUser().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify site contributor user gets specific network with Rest API and response is not empty")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void siteContributorChecksIfNetworkIsPresent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(tenantSiteContributor).withCoreAPI().usingAuthUser().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.NETWORKS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify site consumer user gets specific network with Rest API and response is not empty")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.NETWORKS, TestGroup.SANITY })
|
||||
public void siteConsumerChecksIfNetworkIsPresent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(tenantSiteConsumer).withCoreAPI().usingAuthUser().getNetwork();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user