mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
REPO-2755 / REPO-2251: changed CORE and FULL groups with REGRESSION in tags package
This commit is contained in:
@@ -1,73 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetTagCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private FileModel document;
|
||||
private String tagValue;
|
||||
private RestTagModel tag;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void setUp() throws Exception {
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void invalidTagIdTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
tag.setId("random_tag_value");
|
||||
restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Retrieve and validate the id of a tag added to a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void validateTagIdTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("id").is(tag.getId());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Retrieve and validate the name of a tag added to a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void validateTagNameTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
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.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;
|
||||
|
||||
public class GetTagFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private FileModel document;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void checkPropertiesFilterIsApplied() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=id,tag").withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("id").is(tag.getId())
|
||||
.assertThat().field("tag").is(tag.getTag().toLowerCase())
|
||||
.assertThat().fieldsCount().is(2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void getTagOfAFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tagFolder");
|
||||
FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue);
|
||||
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void checkDefaultErrorModelSchema() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
restClient.withParams("skipCount=abc").withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"))
|
||||
.containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"))
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
+86
-37
@@ -8,23 +8,23 @@ import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
import org.alfresco.utility.model.TestGroup;
|
||||
import org.alfresco.utility.model.UserModel;
|
||||
import org.alfresco.utility.model.*;
|
||||
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.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetTagSanityTests extends RestTest
|
||||
public class GetTagTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private FileModel document;
|
||||
private String tagValue;
|
||||
private RestTagModel tag;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
@@ -36,25 +36,26 @@ public class GetTagSanityTests extends RestTest
|
||||
UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithAdminIsAbletoGetTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void setUp() throws Exception {
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin user gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToGetTag() throws Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(adminUserModel).withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithManagerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception
|
||||
public void userWithManagerRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
@@ -62,12 +63,13 @@ public class GetTagSanityTests extends RestTest
|
||||
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase())
|
||||
.assertThat().field("id").is(tag.getId());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithCollaboratorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithCollaboratorRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
@@ -78,9 +80,9 @@ public class GetTagSanityTests extends RestTest
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithContributorRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithContributorRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
@@ -92,10 +94,9 @@ public class GetTagSanityTests extends RestTest
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void userWithConsumerRoleIsAbletoGetTag() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tag using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userWithConsumerRoleIsAbleToGetTag() throws Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
@@ -109,20 +110,68 @@ public class GetTagSanityTests extends RestTest
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void managerIsNotAbleToGetTagIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void managerIsNotAbleToGetTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
UserModel managerUser = dataUser.usingAdmin().createRandomTestUser();
|
||||
dataUser.addUserToSite(managerUser, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(managerUser);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
managerUser.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(managerUser);
|
||||
restClient.withCoreAPI().getTag(tag);
|
||||
restClient.authenticateUser(managerUser).withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void invalidTagIdTest() throws Exception
|
||||
{
|
||||
tag.setId("random_tag_value");
|
||||
restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "random_tag_value"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that properties filter is applied when getting tag using Manager user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkPropertiesFilterIsApplied() throws Exception
|
||||
{
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=id,tag").withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("id").is(tag.getId())
|
||||
.assertThat().field("tag").is(tag.getTag().toLowerCase())
|
||||
.assertThat().fieldsCount().is(2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check that Manager user can get tag of a folder.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagOfAFolder() throws Exception
|
||||
{
|
||||
String tagValue = RandomData.getRandomName("tagFolder");
|
||||
FolderModel folder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(folder).addTag(tagValue);
|
||||
|
||||
RestTagModel returnedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Check default error model schema. Use invalid skipCount parameter.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("skipCount=abc").withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"))
|
||||
.containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"))
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
public class GetTagsCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
private FileModel document;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
private FolderModel folder;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tagValue);
|
||||
restClient.withCoreAPI().usingResource(folder).addTags(tagValue2);
|
||||
|
||||
Utility.waitToLoopTime(60);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if maxItems is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void maxItemsInvalidValueTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if skipCount is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void skipCountInvalidValueTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that file tag is retrieved")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void fileTagIsRetrieved() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag is retrieved")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void folderTagIsRetrieved() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,148 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
public class GetTagsFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
|
||||
private String tagValue, tagValue2;
|
||||
private FileModel document;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2);
|
||||
|
||||
Utility.waitToLoopTime(20);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site Manager is able to get tags using properties parameter."
|
||||
+ "Check that properties filter is applied.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("maxItems=5000&properties=tag").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase())
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get tags and use skipCount parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void useSkipCountCheckPagination() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel();
|
||||
RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel();
|
||||
RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag())
|
||||
.assertThat().entriesListDoesNotContain("tag", secondTag.getTag());
|
||||
tagsWithSkipCount.assertThat().paginationField("skipCount").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get tags and use maxItems parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel();
|
||||
RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel();
|
||||
RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag())
|
||||
.assertThat().entriesListContains("tag", secondTag.getTag())
|
||||
.assertThat().entriesListCountIs(2);
|
||||
tagsWithMaxItems.assertThat().paginationField("maxItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With manager get tags and use high skipCount parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void useHighSkipCountCheckPagination() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("skipCount=20000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsEmpty()
|
||||
.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is(20000)
|
||||
.and().field("totalItems").isNull();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withParams("maxItems=0").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS)
|
||||
.containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With Manager user delete tag. Check it is not retrieved anymore.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void checkThatDeletedTagIsNotRetrievedAnymore() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String removedTag = RandomData.getRandomName("tag3");
|
||||
|
||||
RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(removedTag);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListDoesNotContain("tag", removedTag.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
public class GetTagsSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private UserModel userModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
private FileModel document;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2);
|
||||
|
||||
Utility.waitToLoopTime(60);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithManagerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithCollaboratorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithContributorRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithConsumerRole() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithAdminUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModelsCollection returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void failedAuthenticationReturnsUnauthorizedStatus() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
restClient.withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.*;
|
||||
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;
|
||||
|
||||
public class GetTagsTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private UserModel userModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
private String tagValue3;
|
||||
private FileModel document;
|
||||
private FolderModel folder;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
document = dataContent.usingUser(adminUserModel).usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
tagValue3 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tagValue, tagValue2);
|
||||
restClient.withCoreAPI().usingResource(folder).addTags(tagValue3);
|
||||
|
||||
Utility.waitToLoopTime(60);
|
||||
}
|
||||
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user with Manager role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void getTagsWithManagerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Collaborator role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithCollaboratorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Contributor role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithContributorRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify user with Consumer role gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithConsumerRole() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Admin user gets tags using REST API and status code is OK (200)")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithAdminUser() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Failed authentication get tags call returns status code 401 with Manager role")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void failedAuthenticationReturnsUnauthorizedStatus() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
userModel.setPassword("user wrong password");
|
||||
dataUser.addUserToSite(userModel, siteModel, UserRole.SiteManager);
|
||||
restClient.authenticateUser(userModel);
|
||||
restClient.withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if maxItems is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void maxItemsInvalidValueTest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("maxItems=abc").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if skipCount is invalid status code returned is 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void skipCountInvalidValueTest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withParams("skipCount=abc").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that file tag is retrieved")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void fileTagIsRetrieved() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag is retrieved")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void folderTagIsRetrieved() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue3.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site Manager is able to get tags using properties parameter."
|
||||
+ "Check that properties filter is applied.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteManagerIsAbleToRetrieveTagsWithPropertiesParameter() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("maxItems=5000&properties=tag").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase())
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get tags and use skipCount parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useSkipCountCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel();
|
||||
RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel();
|
||||
RestTagModelsCollection tagsWithSkipCount = restClient.withParams("skipCount=2").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
tagsWithSkipCount.assertThat().entriesListDoesNotContain("tag", firstTag.getTag())
|
||||
.assertThat().entriesListDoesNotContain("tag", secondTag.getTag());
|
||||
tagsWithSkipCount.assertThat().paginationField("skipCount").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get tags and use maxItems parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useMaxItemsParameterCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
RestTagModel firstTag = returnedCollection.getEntries().get(0).onModel();
|
||||
RestTagModel secondTag = returnedCollection.getEntries().get(1).onModel();
|
||||
RestTagModelsCollection tagsWithMaxItems = restClient.withParams("maxItems=2").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
tagsWithMaxItems.assertThat().entriesListContains("tag", firstTag.getTag())
|
||||
.assertThat().entriesListContains("tag", secondTag.getTag())
|
||||
.assertThat().entriesListCountIs(2);
|
||||
tagsWithMaxItems.assertThat().paginationField("maxItems").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With manager get tags and use high skipCount parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useHighSkipCountCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("skipCount=20000").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListIsEmpty()
|
||||
.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is(20000)
|
||||
.and().field("totalItems").isNull();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With Collaborator user get tags and use maxItems with value zero. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useMaxItemsWithValueZeroCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withParams("maxItems=0").withCoreAPI().getTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
|
||||
.containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS)
|
||||
.containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With Manager user delete tag. Check it is not retrieved anymore.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void checkThatDeletedTagIsNotRetrievedAnymore() throws Exception
|
||||
{
|
||||
String removedTag = RandomData.getRandomName("tag3");
|
||||
|
||||
RestTagModel deletedTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(removedTag);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(deletedTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
returnedCollection = restClient.withParams("maxItems=10000").withCoreAPI().getTags();
|
||||
returnedCollection.assertThat().entriesListIsNotEmpty()
|
||||
.and().entriesListDoesNotContain("tag", removedTag.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by Bogdan Bocancea
|
||||
*/
|
||||
public class UpdateTagCoreTests extends RestTest
|
||||
{
|
||||
private UserModel managerUser;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
@SuppressWarnings("unused")
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
@SuppressWarnings("unused")
|
||||
private RestTagModel oldTag;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
managerUser = dataUser.createRandomTestUser();
|
||||
siteModel = dataSite.usingUser(managerUser).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(managerUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
|
||||
oldTag = restClient.authenticateUser(managerUser).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsNotAbleToUpdateTagWithInvalidId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String invalidTagId = "invalid-id";
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
tag.setId(invalidTagId);
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with empty id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsNotAbleToUpdateTagWithEmptyId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
.assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify site manager is not able to update tag with invalid body")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsNotAbleToUpdateTagWithEmptyBody() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingTag(tag).update("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(RestErrorModel.EMPTY_TAG);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site manager is not able to update tag with invalid body containing '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String invalidTagBody = "|.\"/<>*";
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.waitToLoopTime(20);
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site manager is not able to update tag with invalid body without '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String invalidTagBody = ".\"/<>*";
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.waitToLoopTime(20);
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class UpdateTagFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestTagModel oldTag;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestTagModel returnedModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void addTagToDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Manager user can provide large string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id="REPO-1828")
|
||||
public void managerIsAbleToUpdateTagsProvideLargeStringTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String largeStringTag = RandomStringUtils.randomAlphanumeric(10000);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(largeStringTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Manager user can provide short string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id="REPO-1828")
|
||||
public void managerIsAbleToUpdateTagsProvideShortStringTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String shortStringTag = RandomStringUtils.randomAlphanumeric(2);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(shortStringTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Manager user can provide string with special chars for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id="REPO-1828")
|
||||
public void managerIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(specialCharsString);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can provide existing tag for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideExistingTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String existingTag = "oldTag";
|
||||
RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(existingTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can delete a tag, add tag and update it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id="REPO-1828")
|
||||
public void withAdminDeleteTagAddTagUpdateTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).deleteTag(oldTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
String newTag = "addTag";
|
||||
RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can update a tag, delete tag and add it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id="REPO-1828")
|
||||
public void withAdminUpdateTagDeleteTagAddTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String newTag = "addTag";
|
||||
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTag);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
public class UpdateTagSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestTagModel oldTag;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String randomTag = "";
|
||||
private RestTagModel returnedModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void addTagToDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old"));
|
||||
randomTag = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200")
|
||||
@Bug(id="REPO-1828")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(randomTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void managerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void contributorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void consumerIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
package org.alfresco.rest.tags;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.Utility;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
public class UpdateTagTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private RestTagModel oldTag;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String randomTag = "";
|
||||
private RestTagModel returnedModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun=true)
|
||||
public void addTagToDocument() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
oldTag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("old"));
|
||||
randomTag = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200")
|
||||
@Bug(id="REPO-1828")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToUpdateTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(randomTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerIsNotAbleToUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsNotAbleToUpdateTagCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Contributor user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Consumer user can't update tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToUpdateTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingTag(oldTag).update(randomTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidId() throws Exception
|
||||
{
|
||||
String invalidTagId = "invalid-id";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
tag.setId(invalidTagId);
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, invalidTagId));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with empty id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyId() throws Exception
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingTag(tag).update(RandomData.getRandomName("tag"));
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED)
|
||||
.assertLastError().containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Verify admin is not able to update tag with invalid body")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithEmptyBody() throws Exception
|
||||
{
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingTag(tag).update("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(RestErrorModel.EMPTY_TAG);
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to update tag with invalid body containing '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario1() throws Exception
|
||||
{
|
||||
String invalidTagBody = "|.\"/<>*";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.waitToLoopTime(20);
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
}
|
||||
|
||||
@Bug(id="ACE-5629")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin is not able to update tag with invalid body without '|' symbol")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsNotAbleToUpdateTagWithInvalidBodyScenario2() throws Exception
|
||||
{
|
||||
String invalidTagBody = ".\"/<>*";
|
||||
RestTagModel tag = restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
Utility.waitToLoopTime(20);
|
||||
restClient.withCoreAPI().usingTag(tag).update(invalidTagBody);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST)
|
||||
.assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, invalidTagBody));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide large string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideLargeStringTag() throws Exception
|
||||
{
|
||||
String largeStringTag = RandomStringUtils.randomAlphanumeric(10000);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(largeStringTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(largeStringTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide short string for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideShortStringTag() throws Exception
|
||||
{
|
||||
String shortStringTag = RandomStringUtils.randomAlphanumeric(2);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(shortStringTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(shortStringTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user can provide string with special chars for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideSpecialCharsStringTag() throws Exception
|
||||
{
|
||||
String specialCharsString = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldTag).update(specialCharsString);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(specialCharsString);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can provide existing tag for new tag value.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminIsAbleToUpdateTagsProvideExistingTag() throws Exception
|
||||
{
|
||||
String existingTag = "oldTag";
|
||||
RestTagModel oldExistingTag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).addTag(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingTag(oldExistingTag).update(existingTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(existingTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can delete a tag, add tag and update it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminDeleteTagAddTagUpdateTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).deleteTag(oldTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
String newTag = "addTag";
|
||||
RestTagModel newTagModel = restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingTag(newTagModel).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTag);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user can update a tag, delete tag and add it.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id="REPO-1828")
|
||||
public void adminUpdateTagDeleteTagAddTag() throws Exception
|
||||
{
|
||||
String newTag = "addTag";
|
||||
|
||||
returnedModel = restClient.authenticateUser(adminUserModel).withCoreAPI().usingTag(oldTag).update(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedModel.assertThat().field("tag").is(newTag);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(returnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).addTag(newTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class AddTagCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private UserModel testUser;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private String tagValue;
|
||||
private RestTagModel returnedModel;
|
||||
private FolderModel folderModel;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
testUser = dataUser.createRandomTestUser();
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTag()
|
||||
{
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding empty tag returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void emptyTagTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag with user that has no permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void addTagWithUserThatDoesNotHavePermissions() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(testUser);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag to a node that does not exist returns status code 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void addTagToInexistentNode() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag to a node that does not accepts tags returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void addTagToANodeThatDoesNotAcceptsTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
document.setNodeRef(returnedModel.getId());
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager is able to tag a file")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsAbleToTagAFile() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void managerIsAbleToTagAFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged file can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void addTagToATaggedFile() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty();
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", "random_tag_value");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user cannot add invalid tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void addInvalidTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_=");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|"));
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.exception.DataPreparationException;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class AddTagFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String tagValue;
|
||||
private RestTagModel returnedModel;
|
||||
private RestCommentModel returnedModelComment;
|
||||
private RestTagModelsCollection returnedModelTags;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws DataPreparationException
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTag() throws DataPreparationException, Exception
|
||||
{
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that contributor is able to tag a folder created by self")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void contributorIsAbleToTagAFolderCreatedBySelf() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that collaborator is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void collaboratorIsAbleToTagAFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that consumer is not able to tag a folder. Check default error model schema.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void consumerIsNotAbleToTagAFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged folder can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void addTagToATaggedFolder() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty();
|
||||
|
||||
restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", "random_tag_value")
|
||||
.and().entriesListCountIs(2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using collaborator provide more than one tag element")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void provideMoreThanOneTagElement() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String tagValue1 = RandomData.getRandomName("tag1");
|
||||
String tagValue2 = RandomData.getRandomName("tag2");
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModelTags.assertThat().entriesListContains("tag", tagValue)
|
||||
.and().entriesListContains("tag", tagValue1)
|
||||
.and().entriesListContains("tag", tagValue2)
|
||||
.and().entriesListCountIs(3);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager cannot add tag with special characters.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void addTagWithSpecialCharacters() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(folderModel).addTag(specialCharsTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a comment and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void addTagToAComment() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String comment = "comment for a tag";
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment);
|
||||
file.setNodeRef(returnedModelComment.getId());
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a tag and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void addTagToATag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
file.setNodeRef(returnedModel.getId());
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/3/2016.
|
||||
*/
|
||||
public class AddTagSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String tagValue;
|
||||
private RestTagModel returnedModel;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTag()
|
||||
{
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToAddTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void contributorIsNotAbleToAddTagToAnotherContent() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToAddTagToHisContent() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("id").isNotEmpty()
|
||||
.and().field("tag").is(tagValue);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void consumerIsNotAbleToAddTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestCommentModel;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.*;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.BeforeMethod;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/3/2016.
|
||||
*/
|
||||
public class AddTagTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private FileModel document;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private String tagValue;
|
||||
private RestTagModel returnedModel;
|
||||
private RestCommentModel returnedModelComment;
|
||||
private RestTagModelsCollection returnedModelTags;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
}
|
||||
|
||||
@BeforeMethod(alwaysRun = true)
|
||||
public void generateRandomTag()
|
||||
{
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToAddTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToTagAFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Collaborator user adds tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToTagAFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue)
|
||||
.and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToAddTagToAnotherContent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user adds tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToAddTagToHisContent() throws Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
FileModel contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(contributorDoc).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("id").isNotEmpty()
|
||||
.and().field("tag").is(tagValue);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user doesn't have permission to add tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToTagAFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingResource(document).addTag("tagUnauthorized");
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding empty tag returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void emptyTagTest() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.NULL_ARGUMENT, "tag"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag with user that has no permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagWithUserThatDoesNotHavePermissions() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser());
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that adding tag to a node that does not exist returns status code 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToInexistentNode() throws Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify that manager is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToTagAFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged file can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATaggedFile() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("random_tag_value");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty();
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags().assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", "random_tag_value");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user cannot add invalid tag")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addInvalidTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(document).addTag("-1~!|@#$%^&*()_=");
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that contributor is able to tag a folder created by self")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToTagAFolderCreatedBySelf() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that collaborator is able to tag a folder")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToTagAFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that consumer is not able to tag a folder. Check default error model schema.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToTagAFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
|
||||
.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that tagged folder can be tagged again")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATaggedFolder() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is(tagValue).and().field("id").isNotEmpty();
|
||||
|
||||
returnedModel = restClient.withCoreAPI().usingResource(folderModel).addTag("random_tag_value");
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModel.assertThat().field("tag").is("random_tag_value").and().field("id").isNotEmpty();
|
||||
|
||||
restClient.withCoreAPI().usingResource(folderModel).getNodeTags().assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", "random_tag_value")
|
||||
.and().entriesListCountIs(2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using collaborator provide more than one tag element")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void provideMoreThanOneTagElement() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String tagValue1 = RandomData.getRandomName("tag1");
|
||||
String tagValue2 = RandomData.getRandomName("tag2");
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
returnedModelTags = restClient.withCoreAPI().usingResource(folderModel).addTags(tagValue, tagValue1, tagValue2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.CREATED);
|
||||
returnedModelTags.assertThat().entriesListContains("tag", tagValue)
|
||||
.and().entriesListContains("tag", tagValue1)
|
||||
.and().entriesListContains("tag", tagValue2)
|
||||
.and().entriesListCountIs(3);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that manager cannot add tag with special characters.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagWithSpecialCharacters() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
String specialCharsTag = "!@#$%^&*()'\".,<>-_+=|\\";
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(folderModel).addTag(specialCharsTag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_TAG, "|"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a comment and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToAComment() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String comment = "comment for a tag";
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModelComment = restClient.withCoreAPI().usingResource(file).addComment(comment);
|
||||
file.setNodeRef(returnedModelComment.getId());
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that you cannot tag a tag and it returns status code 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void addTagToATag() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedModel = restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
file.setNodeRef(returnedModel.getId());
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.CANNOT_TAG);
|
||||
}
|
||||
}
|
||||
+28
-29
@@ -2,7 +2,6 @@ package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
@@ -12,7 +11,6 @@ import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
@@ -23,7 +21,7 @@ import org.testng.annotations.Test;
|
||||
/**
|
||||
* Created by Claudia Agache on 10/7/2016.
|
||||
*/
|
||||
public class AddTagsSanityTests extends RestTest
|
||||
public class AddTagsTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private FileModel document, contributorDoc;
|
||||
@@ -49,10 +47,10 @@ public class AddTagsSanityTests extends RestTest
|
||||
tag2 = RandomData.getRandomName("tag");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify admin user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToAddTags() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify admin user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -61,10 +59,10 @@ public class AddTagsSanityTests extends RestTest
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user adds multiple tags with Rest API and status code is 201")
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToAddTags() throws JsonToModelConversionException, Exception
|
||||
public void managerIsAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -73,10 +71,10 @@ public class AddTagsSanityTests extends RestTest
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToAddTags() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Collaborator user adds multiple tags with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
@@ -85,20 +83,20 @@ public class AddTagsSanityTests extends RestTest
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void contributorIsNotAbleToAddTagsToAnotherContent() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToAddTagsToAnotherContent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToAddTagsToHisContent() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user adds multiple tags to his content with Rest API and status code is 201")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToAddTagsToHisContent() throws Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
@@ -109,19 +107,20 @@ public class AddTagsSanityTests extends RestTest
|
||||
.and().entriesListContains("tag", tag2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void consumerIsNotAbleToAddTags() throws JsonToModelConversionException, Exception
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user doesn't have permission to add multiple tags with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToAddTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).withCoreAPI().usingResource(document).addTags(tag1, tag2);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@TestRail(section = { TestGroup.REST_API,TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagsIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToAddTagsIfAuthenticationFails() throws Exception
|
||||
{
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
@@ -1,124 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class DeleteTagCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private UserModel userModel;
|
||||
private SiteModel siteModel;
|
||||
private FileModel document;
|
||||
private FolderModel folderModel;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(userModel);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
|
||||
.containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void deleteTagForAnInexistentNode() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void deleteTagThatDoesNotExist() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag.setId("abc");
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is empty returned status code is 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void deleteTagWithEmptyId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that file tag can be deleted")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void deleteFileTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags()
|
||||
.assertThat().entriesListDoesNotContain("tag", tag.getTag());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag can be deleted")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void deleteFolderTag() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(folderModel).getNodeTags()
|
||||
.assertThat().entriesListDoesNotContain("tag", tag.getTag());
|
||||
}
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class DeleteTagFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestTagModel tagReturnedModel, returnedTag;
|
||||
private FileModel document;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
@Bug(id = "ACE-5455")
|
||||
public void managerCannotDeleteDeletedTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
tagReturnedModel = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void userCollaboratorCanDeleteLongTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String longTag = RandomStringUtils.randomAlphanumeric(800);
|
||||
|
||||
tagReturnedModel = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(longTag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void managerCanDeleteShortTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String shortTag = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tagReturnedModel = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(shortTag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void adminRemovesTagAndAddsItAgain() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String tag = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tagReturnedModel = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(tag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
tagReturnedModel = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(tag);
|
||||
returnedTag = restClient.withCoreAPI().getTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tag.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void managerCanDeleteTagAddedByAnotherUser() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String tag = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tagReturnedModel = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addTag(tag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tagReturnedModel);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
public class DeleteTagSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestTagModel tag;
|
||||
private FileModel document, contributorDoc;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user deletes tags with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToDeleteTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToDeleteTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void collaboratorIsAbleToDeleteTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void contributorIsAbleToDeleteTagsForHisContent() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);;
|
||||
tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS })
|
||||
public void consumerIsNotAbleToDeleteTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API,
|
||||
TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,288 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModel;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.*;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by Claudia Agache on 10/4/2016.
|
||||
*/
|
||||
public class DeleteTagTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private SiteModel siteModel;
|
||||
private DataUser.ListUserWithRoles usersWithRoles;
|
||||
private RestTagModel tag;
|
||||
private FileModel document, contributorDoc;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Admin user deletes tags with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags()
|
||||
.assertThat().entriesListDoesNotContain("tag", tag.getTag());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify Manager user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void managerIsAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Collaborator user deletes tags created by admin user with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorIsAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsNotAbleToDeleteTagsForAnotherUserContent() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Contributor user deletes tags created by him with Rest API and status code is 204")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void contributorIsAbleToDeleteTagsForHisContent() throws Exception
|
||||
{
|
||||
userModel = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor);
|
||||
restClient.authenticateUser(userModel);
|
||||
contributorDoc = dataContent.usingSite(siteModel).usingUser(userModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);;
|
||||
tag = restClient.withCoreAPI().usingResource(contributorDoc).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify Consumer user can't delete tags created by admin user with Rest API and status code is 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void consumerIsNotAbleToDeleteTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
|
||||
description = "Verify user gets status code 401 if authentication call fails")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id="MNT-16904", description = "It fails only on environment with tenants")
|
||||
public void userIsNotAbleToDeleteTagIfAuthenticationFails() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
UserModel siteManager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager);
|
||||
siteManager.setPassword("wrongPassword");
|
||||
restClient.authenticateUser(siteManager);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if user has no permission to remove tag returned status code is 403. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagWithUserWithoutPermissionCheckDefaultErrorModelSchema() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser());
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError()
|
||||
.containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagForANonexistentNode() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag does not exist returned status code is 404")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagThatDoesNotExist() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag.setId("abc");
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "abc"));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if tag id is empty returned status code is 405")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteTagWithEmptyId() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
tag.setId("");
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError().containsSummary(RestErrorModel.DELETE_EMPTY_ARGUMENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that folder tag can be deleted")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void deleteFolderTag() throws Exception
|
||||
{
|
||||
FolderModel folderModel = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();;
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
RestTagModel tag = restClient.withCoreAPI().usingResource(folderModel).addTag(RandomData.getRandomName("tag"));
|
||||
restClient.withCoreAPI().usingResource(folderModel).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
restClient.withCoreAPI().usingResource(folderModel).getNodeTags()
|
||||
.assertThat().entriesListDoesNotContain("tag", tag.getTag());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can't delete deleted tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
@Bug(id = "ACE-5455")
|
||||
public void managerCannotDeleteDeletedTag() throws Exception
|
||||
{
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(RandomData.getRandomName("tag"));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
restClient.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Collaborator user can delete long tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void userCollaboratorCanDeleteLongTag() throws Exception
|
||||
{
|
||||
String longTag = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(800);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(longTag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete short tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerCanDeleteShortTag() throws Exception
|
||||
{
|
||||
String shortTag = org.apache.commons.lang.RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(shortTag);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Admin can delete tag then add it again.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminRemovesTagAndAddsItAgain() throws Exception
|
||||
{
|
||||
String tagValue = RandomStringUtils.randomAlphanumeric(10);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
|
||||
tag = restClient.authenticateUser(adminUserModel)
|
||||
.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
RestTagModel returnedTag = restClient.withCoreAPI().getTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedTag.assertThat().field("tag").is(tagValue.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify Manager user can delete tag added by another user.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void managerCanDeleteTagAddedByAnotherUser() throws Exception
|
||||
{
|
||||
tag = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
|
||||
.withCoreAPI().usingResource(document).addTag(RandomStringUtils.randomAlphanumeric(10));
|
||||
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(document).deleteTag(tag);
|
||||
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.FolderModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetNodeTagsCoreTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private SiteModel siteModel;
|
||||
private FileModel document;
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using invalid value for skipCount parameter returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void invalidSkipCountTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"));
|
||||
|
||||
restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using invalid value for maxItems parameter returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void invalidMaxItemsTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc"));
|
||||
|
||||
restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user without permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void userWithoutPermissionsTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite();
|
||||
FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
restClient.authenticateUser(userModel).withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void inexistentNodeTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node id is empty returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void emptyNodeIdTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
document.setNodeRef("");
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, ""));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify file tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void fileTagsTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags()
|
||||
.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify folder tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.CORE })
|
||||
public void folderTagsTest() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(folder).addTag(tagValue);
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(folder).addTag(tagValue2);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags()
|
||||
.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.dataprep.CMISUtil.DocumentType;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
public class GetNodeTagsFullTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel, userModel;
|
||||
private SiteModel siteModel;
|
||||
private FileModel document;
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
userModel = dataUser.createRandomTestUser();
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPrivateRandomSite();
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
|
||||
UserRole.SiteContributor);
|
||||
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site Manager is able to get node tags using properties parameter")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase())
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that Collaborator user is not able to get node tags using site id instead of node id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
file.setNodeRef(siteModel.getId());
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void useSkipCountCheckPaginationAndMaxItems() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is(2)
|
||||
.and().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use maxItems parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void useMaxItemsParameterCheckPagination() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(1)
|
||||
.and().field("hasMoreItems").is("true")
|
||||
.and().field("totalItems").is("2")
|
||||
.and().field("count").is("1")
|
||||
.and().field("skipCount").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Get tags from a node to which user does not have access. Check default error model schema")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void getTagsFromNodeWithUserWhoDoesNotHaveAccessCheckDefaultErrorModelSchema() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(userModel)
|
||||
.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using manager user get only one tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void usingManagerGetOnlyOneTag() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("1")
|
||||
.and().field("count").is("1")
|
||||
.and().field("skipCount").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using admin get last 2 tags and skip first 2 tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void adminUserGetLast2TagsAndSkipFirst2Tags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
String firstTag = "1st tag";
|
||||
String secondTag = "2nd tag";
|
||||
String thirdTag = "3rd tag";
|
||||
String fourthTag = "4th tag";
|
||||
FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(secondTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(thirdTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(fourthTag);
|
||||
|
||||
returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase())
|
||||
.and().entriesListContains("tag", fourthTag.toLowerCase());
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("4")
|
||||
.and().field("count").is("2")
|
||||
.and().field("skipCount").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use maxItems=0.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void getTagsWithZeroMaxItems() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using high skipCount parameter returns status code 200.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.FULL })
|
||||
public void getTagsWithHighSkipCount() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000")
|
||||
.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("2")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is("10000");
|
||||
returnedCollection.assertThat().entriesListCountIs(0);
|
||||
}
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.FileModel;
|
||||
import org.alfresco.utility.model.SiteModel;
|
||||
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;
|
||||
|
||||
public class GetNodeTagsSanityTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private FileModel document;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void siteManagerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify site Collaborator is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void siteCollaboratorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify site Contributor is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void siteContributorIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify site Consumer is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void siteConsumerIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify admin is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void adminIsAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
@Bug(id = "MNT-16904", description = "fails only on environment with tenants")
|
||||
public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws JsonToModelConversionException, Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,339 @@
|
||||
package org.alfresco.rest.tags.nodes;
|
||||
|
||||
import org.alfresco.dataprep.CMISUtil;
|
||||
import org.alfresco.rest.RestTest;
|
||||
import org.alfresco.rest.exception.JsonToModelConversionException;
|
||||
import org.alfresco.rest.model.RestErrorModel;
|
||||
import org.alfresco.rest.model.RestTagModelsCollection;
|
||||
import org.alfresco.utility.constants.UserRole;
|
||||
import org.alfresco.utility.data.DataUser.ListUserWithRoles;
|
||||
import org.alfresco.utility.data.RandomData;
|
||||
import org.alfresco.utility.model.*;
|
||||
import org.alfresco.utility.report.Bug;
|
||||
import org.alfresco.utility.testrail.ExecutionType;
|
||||
import org.alfresco.utility.testrail.annotation.TestRail;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class GetNodeTagsTests extends RestTest
|
||||
{
|
||||
private UserModel adminUserModel;
|
||||
private SiteModel siteModel;
|
||||
private ListUserWithRoles usersWithRoles;
|
||||
private FileModel document;
|
||||
private RestTagModelsCollection returnedCollection;
|
||||
private String tagValue;
|
||||
private String tagValue2;
|
||||
|
||||
@BeforeClass(alwaysRun=true)
|
||||
public void dataPreparation() throws Exception
|
||||
{
|
||||
adminUserModel = dataUser.getAdminUser();
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
|
||||
|
||||
usersWithRoles = dataUser.addUsersWithRolesToSite(siteModel,
|
||||
UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor);
|
||||
document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
tagValue = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
tagValue2 = RandomData.getRandomName("tag");
|
||||
restClient.withCoreAPI().usingResource(document).addTag(tagValue2);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify site Manager is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
public void siteManagerIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify site Collaborator is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteCollaboratorIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify site Contributor is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteContributorIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify site Consumer is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteConsumerIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer));
|
||||
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.REGRESSION, description = "Verify admin is able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminIsAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(adminUserModel);
|
||||
returnedCollection = restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS },
|
||||
executionType = ExecutionType.SANITY, description = "Verify unauthenticated user is not able to get node tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
|
||||
// @Bug(id = "MNT-16904", description = "fails only on environment with tenants")
|
||||
public void unauthenticatedUserIsNotAbleToRetrieveNodeTags() throws Exception
|
||||
{
|
||||
restClient.authenticateUser(new UserModel("random user", "random password"));
|
||||
restClient.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED).assertLastError()
|
||||
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using invalid value for skipCount parameter returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void invalidSkipCountTest() throws Exception
|
||||
{
|
||||
restClient.withParams("skipCount=abc").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "abc"));
|
||||
|
||||
restClient.withParams("skipCount=-1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using invalid value for maxItems parameter returns status code 400")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void invalidMaxItemsTest() throws Exception
|
||||
{
|
||||
restClient.withParams("maxItems=abc").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "abc"));
|
||||
|
||||
restClient.withParams("maxItems=-1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that user without permissions returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void userWithoutPermissionsTest() throws Exception
|
||||
{
|
||||
SiteModel site = dataSite.usingUser(adminUserModel).createModeratedRandomSite();
|
||||
FileModel document = dataContent.usingSite(site).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String tagValue = RandomData.getRandomName("tag");
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).addTag(tagValue);
|
||||
|
||||
restClient.authenticateUser(dataUser.createRandomTestUser()).withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
|
||||
.containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY)
|
||||
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
|
||||
.stackTraceIs(RestErrorModel.STACKTRACE);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node does not exist returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void nonexistentNodeTest() throws Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
String nodeRef = RandomStringUtils.randomAlphanumeric(10);
|
||||
document.setNodeRef(nodeRef);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, nodeRef));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that if node id is empty returns status code 403")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void emptyNodeIdTest() throws Exception
|
||||
{
|
||||
FileModel document = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
document.setNodeRef("");
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, ""));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify folder tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION})
|
||||
public void folderTagsTest() throws Exception
|
||||
{
|
||||
FolderModel folder = dataContent.usingUser(adminUserModel).usingSite(siteModel).createFolder();
|
||||
|
||||
restClient.withCoreAPI().usingResource(folder).addTag(tagValue);
|
||||
restClient.withCoreAPI().usingResource(folder).addTag(tagValue2);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(folder).getNodeTags()
|
||||
.assertThat()
|
||||
.entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase());
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify site Manager is able to get node tags using properties parameter")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void siteManagerIsAbleToRetrieveNodeTagsWithPropertiesParameter() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withParams("properties=tag").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.assertThat().entriesListContains("tag", tagValue.toLowerCase())
|
||||
.and().entriesListContains("tag", tagValue2.toLowerCase())
|
||||
.and().entriesListDoesNotContain("id");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that Collaborator user is not able to get node tags using site id instead of node id")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void collaboratorGetNodeTagsUseSiteIdInsteadOfNodeId() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingSite(siteModel).usingUser(adminUserModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
file.setNodeRef(siteModel.getId());
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
|
||||
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, file.getNodeRef()));
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use skipCount parameter. Check pagination and maxItems")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useSkipCountCheckPaginationAndMaxItems() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("skipCount=1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is(2)
|
||||
.and().field("count").is("1");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use maxItems parameter. Check pagination")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void useMaxItemsParameterCheckPagination() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("maxItems=1").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(1)
|
||||
.and().field("hasMoreItems").is("true")
|
||||
.and().field("totalItems").is("2")
|
||||
.and().field("count").is("1")
|
||||
.and().field("skipCount").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using manager user get only one tag.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void usingManagerGetOnlyOneTag() throws Exception
|
||||
{
|
||||
FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(tagValue);
|
||||
|
||||
returnedCollection = restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
|
||||
.withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("1")
|
||||
.and().field("count").is("1")
|
||||
.and().field("skipCount").is("0");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Using admin get last 2 tags and skip first 2 tags")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void adminUserGetLast2TagsAndSkipFirst2Tags() throws Exception
|
||||
{
|
||||
String firstTag = "1st tag";
|
||||
String secondTag = "2nd tag";
|
||||
String thirdTag = "3rd tag";
|
||||
String fourthTag = "4th tag";
|
||||
FileModel file = dataContent.usingAdmin().usingSite(siteModel).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
|
||||
|
||||
restClient.authenticateUser(adminUserModel).withCoreAPI().usingResource(file).addTag(firstTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(secondTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(thirdTag);
|
||||
restClient.withCoreAPI().usingResource(file).addTag(fourthTag);
|
||||
|
||||
returnedCollection = restClient.withParams("skipCount=2").withCoreAPI().usingResource(file).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
|
||||
returnedCollection.assertThat().entriesListContains("tag", thirdTag.toLowerCase())
|
||||
.and().entriesListContains("tag", fourthTag.toLowerCase());
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("4")
|
||||
.and().field("count").is("2")
|
||||
.and().field("skipCount").is("2");
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "With admin get node tags and use maxItems=0.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithZeroMaxItems() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel)
|
||||
.withParams("maxItems=0").withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS);
|
||||
}
|
||||
|
||||
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION,
|
||||
description = "Verify that using high skipCount parameter returns status code 200.")
|
||||
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.REGRESSION })
|
||||
public void getTagsWithHighSkipCount() throws Exception
|
||||
{
|
||||
returnedCollection = restClient.authenticateUser(adminUserModel).withParams("skipCount=10000")
|
||||
.withCoreAPI().usingResource(document).getNodeTags();
|
||||
restClient.assertStatusCodeIs(HttpStatus.OK);
|
||||
returnedCollection.getPagination().assertThat().field("maxItems").is(100)
|
||||
.and().field("hasMoreItems").is("false")
|
||||
.and().field("totalItems").is("2")
|
||||
.and().field("count").is("0")
|
||||
.and().field("skipCount").is("10000");
|
||||
returnedCollection.assertThat().entriesListCountIs(0);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user