TAS-711 getNetworks

This commit is contained in:
Cristina Jalba
2016-10-07 19:20:44 +03:00
parent 6751e8b9cf
commit d50865c550
6 changed files with 101 additions and 13 deletions
@@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
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.beans.factory.annotation.Autowired;
@@ -92,6 +93,7 @@ public class GetCommentsSanityTests extends RestTest
@TestRail(section={"rest-api", "comments"}, executionType= ExecutionType.SANITY,
description= "Verify Manager user gets status code 401 if authentication call fails")
@Bug(id="MNT-16904")
public void managerIsNotAbleToRetrieveCommentIfAuthenticationFails() throws JsonToModelConversionException, Exception
{
UserModel nonexistentModel = new UserModel("nonexistentUser", "nonexistentPassword");
@@ -10,6 +10,7 @@ import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
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.beans.factory.annotation.Autowired;
@@ -88,6 +89,7 @@ public class PostCommentsSanityTests extends RestTest
@TestRail(section = { "rest-api",
"comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on post comments call")
@Bug(id="MNT-16904")
public void unauthenticatedUserIsNotAbleToAddComment() throws JsonToModelConversionException, Exception
{
restClient.authenticateUser(new UserModel("random user", "random password"));
@@ -111,6 +111,7 @@ public class UpdateCommentsSanityTests extends RestTest
@TestRail(section = { "rest-api",
"comments" }, executionType = ExecutionType.SANITY, description = "Verify unauthenticated user gets status code 401 on update comment call")
@Bug(id="MNT-16904")
public void unauthenticatedUserIsNotAbleToUpdateComment() throws JsonToModelConversionException, Exception
{
UserModel incorrectUserModel = new UserModel("userName", "password");
@@ -1,14 +1,11 @@
package org.alfresco.rest.favorites;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.JsonToModelConversionException;
import org.alfresco.rest.requests.RestFavoritesApi;
import org.alfresco.rest.requests.RestSitesApi;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FolderModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.UserModel;
import org.alfresco.utility.report.Bug;
@@ -30,8 +27,6 @@ public class DeleteFavoritesSanityTests extends RestTest
private UserModel adminUserModel;
private SiteModel siteModel;
private FileModel fileModel;
private FolderModel folderModel;
private ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
@@ -40,8 +35,6 @@ public class DeleteFavoritesSanityTests extends RestTest
adminUserModel = dataUser.getAdminUser();
restClient.authenticateUser(adminUserModel);
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
fileModel = dataContent.usingUser(adminUserModel).usingResource(folderModel).createContent(DocumentType.TEXT_PLAIN);
favoritesAPI.useRestClient(restClient);
sitesApi.useRestClient(restClient);
@@ -109,7 +102,7 @@ public class DeleteFavoritesSanityTests extends RestTest
favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel);
favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
}
@TestRail(section = { "rest-api",
@@ -121,7 +114,7 @@ public class DeleteFavoritesSanityTests extends RestTest
favoritesAPI.addSiteToFavorites(adminUserModel, siteModel);
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
favoritesAPI.deleteSiteFromFavorites(adminUserModel, siteModel);
favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
}
@TestRail(section = { "rest-api",
@@ -133,7 +126,7 @@ public class DeleteFavoritesSanityTests extends RestTest
favoritesAPI.addSiteToFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel);
restClient.authenticateUser(adminUserModel);
favoritesAPI.deleteSiteFromFavorites(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator), siteModel);
favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
favoritesAPI.usingRestWrapper().assertStatusCodeIs(HttpStatus.FORBIDDEN);
}
@TestRail(section = { "rest-api",
@@ -4,6 +4,7 @@ import org.alfresco.rest.RestTest;
import org.alfresco.rest.requests.RestNetworksApi;
import org.alfresco.rest.requests.RestTenantApi;
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.beans.factory.annotation.Autowired;
@@ -34,10 +35,11 @@ public class RestGetNetworkForPersonSanityTests extends RestTest
tenantApi.useRestClient(restClient);
tenantApi.createTenant(adminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createRandomTestUser("uTenant");
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
networkApi.useRestClient(restClient);
}
@Bug(id = "MNT-16904")
@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")
@@ -67,7 +69,7 @@ public class RestGetNetworkForPersonSanityTests extends RestTest
{
restClient.authenticateUser(tenantUser);
networkApi.getNetworkForUser(adminTenantUser);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
@Test(groups = "sanity")
@@ -75,10 +77,12 @@ public class RestGetNetworkForPersonSanityTests extends RestTest
"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")
public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception
{
UserModel secondAdminTenantUser = UserModel.getAdminTenantUser();
tenantApi.createTenant(secondAdminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant");
restClient.authenticateUser(adminTenantUser);
networkApi.getNetworkForUser(tenantUser);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
}
@@ -0,0 +1,86 @@
package org.alfresco.rest.networks;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.requests.RestNetworksApi;
import org.alfresco.rest.requests.RestTenantApi;
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.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = { "rest-api", "networks", "sanity" })
public class RestGetNetworksForPersonSanityTests extends RestTest
{
@Autowired
RestTenantApi tenantApi;
@Autowired
RestNetworksApi networkApi;
private UserModel adminUserModel;
UserModel adminTenantUser;
UserModel tenantUser;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUserModel = dataUser.getAdminUser();
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUserModel);
tenantApi.useRestClient(restClient);
tenantApi.createTenant(adminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
networkApi.useRestClient(restClient);
}
@Bug(id = "MNT-16904")
@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")
public void nonExistingTenantUserIsNotAuthorizedToRequest() throws Exception
{
UserModel tenantUser = new UserModel("nonexisting", "password");
tenantUser.setDomain(adminTenantUser.getDomain());
restClient.authenticateUser(tenantUser);
networkApi.getNetworksForUser(adminTenantUser);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
}
@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")
public void adminTenantChecksIfNetworkIsPresent() throws Exception
{
restClient.authenticateUser(adminTenantUser);
networkApi.getNetworksForUser(adminTenantUser);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.OK);
}
@Test(groups = "sanity")
@TestRail(section = { "rest-api",
"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")
public void tenantUserIsNotAuthorizedToCheckNetworkOfAdminUser() throws Exception
{
restClient.authenticateUser(tenantUser);
networkApi.getNetworksForUser(adminTenantUser);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
@Test(groups = "sanity")
@TestRail(section = { "rest-api",
"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")
public void adminTenantUserIsNotAuthorizedToCheckNetworkOfAnotherUser() throws Exception
{
UserModel secondAdminTenantUser = UserModel.getAdminTenantUser();
tenantApi.createTenant(secondAdminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("anotherTenant");
restClient.authenticateUser(secondAdminTenantUser);
networkApi.getNetworksForUser(tenantUser);
networkApi.usingRestWrapper().assertStatusCodeIs(HttpStatus.NOT_FOUND);
}
}