This commit is contained in:
mionescu
2017-02-06 14:56:55 +02:00
parent 293a48903a
commit 81c896c9fc
9 changed files with 849 additions and 51 deletions
@@ -1,11 +1,8 @@
package org.alfresco.rest;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.model.RestActivityModelsCollection;
import org.alfresco.rest.model.RestFavoriteSiteModel;
import org.alfresco.rest.model.RestSiteMemberModel;
import org.alfresco.rest.model.RestSiteMembershipRequestModelsCollection;
import org.alfresco.rest.model.RestTaskModel;
import org.alfresco.rest.model.*;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.SiteModel;
@@ -19,22 +16,23 @@ import org.testng.annotations.Test;
public class FunctionalCasesTests extends RestTest
{
private UserModel adminUserModel;
private SiteModel siteModel, moderatedSite;
private UserModel adminUser, manager;
private SiteModel publicSite, moderatedSite, privateSite;
private RestSiteMemberModel updatedMember;
private RestSiteMembershipRequestModelsCollection returnedCollection;
private RestFavoriteSiteModel restFavoriteSiteModel;
private RestActivityModelsCollection activities;
private UserModel user;
private FileModel file;
@BeforeClass(alwaysRun=true)
public void dataPreparation() throws Exception
{
adminUserModel = dataUser.getAdminUser();
user = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(adminUserModel).createPublicRandomSite();
dataUser.addUserToSite(user, siteModel, UserRole.SiteManager);
moderatedSite = dataSite.usingUser(adminUserModel).createModeratedRandomSite();
adminUser = dataUser.getAdminUser();
manager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(adminUser).createPublicRandomSite();
dataUser.addUserToSite(manager, publicSite, UserRole.SiteManager);
moderatedSite = dataSite.usingUser(adminUser).createModeratedRandomSite();
privateSite = dataSite.usingUser(adminUser).createPrivateRandomSite();
}
/**
@@ -51,26 +49,26 @@ public class FunctionalCasesTests extends RestTest
{
UserModel testUser = dataUser.createRandomTestUser("testUser");
testUser.setUserRole(UserRole.SiteManager);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser)
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser)
.assertThat().field("id").is(testUser.getUsername())
.and().field("role").is(testUser.getUserRole());
restClient.assertStatusCodeIs(HttpStatus.CREATED);
testUser.setUserRole(UserRole.SiteCollaborator);
updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI()
.usingSite(siteModel).updateSiteMember(testUser);
updatedMember = restClient.withCoreAPI()
.usingSite(publicSite).updateSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole());
testUser.setUserRole(UserRole.SiteContributor);
updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI()
.usingSite(siteModel).updateSiteMember(testUser);
updatedMember = restClient.withCoreAPI()
.usingSite(publicSite).updateSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole());
testUser.setUserRole(UserRole.SiteConsumer);
updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI()
.usingSite(siteModel).updateSiteMember(testUser);
updatedMember = restClient.withCoreAPI()
.usingSite(publicSite).updateSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole());
}
@@ -89,26 +87,26 @@ public class FunctionalCasesTests extends RestTest
{
UserModel testUser = dataUser.createRandomTestUser("testUser");
testUser.setUserRole(UserRole.SiteConsumer);
restClient.authenticateUser(adminUserModel).withCoreAPI().usingSite(siteModel).addPerson(testUser)
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(publicSite).addPerson(testUser)
.assertThat().field("id").is(testUser.getUsername())
.and().field("role").is(testUser.getUserRole());
restClient.assertStatusCodeIs(HttpStatus.CREATED);
testUser.setUserRole(UserRole.SiteContributor);
updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI()
.usingSite(siteModel).updateSiteMember(testUser);
updatedMember = restClient.withCoreAPI()
.usingSite(publicSite).updateSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole());
testUser.setUserRole(UserRole.SiteCollaborator);
updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI()
.usingSite(siteModel).updateSiteMember(testUser);
updatedMember = restClient.withCoreAPI()
.usingSite(publicSite).updateSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole());
testUser.setUserRole(UserRole.SiteManager);
updatedMember = restClient.authenticateUser(adminUserModel).withCoreAPI()
.usingSite(siteModel).updateSiteMember(testUser);
updatedMember = restClient.withCoreAPI()
.usingSite(publicSite).updateSiteMember(testUser);
restClient.assertStatusCodeIs(HttpStatus.OK);
updatedMember.assertThat().field("id").is(testUser.getUsername()).and().field("role").is(testUser.getUserRole());
}
@@ -131,7 +129,7 @@ public class FunctionalCasesTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.CREATED);
RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite);
workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Approve");
workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Approve");
returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId());
@@ -164,7 +162,7 @@ public class FunctionalCasesTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.CREATED);
RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite);
workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), false, "Rejected");
workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), false, "Rejected");
returnedCollection = restClient.authenticateUser(newMember).withCoreAPI().usingMe().getSiteMembershipRequests();
restClient.assertStatusCodeIs(HttpStatus.OK);
returnedCollection.assertThat().entriesListDoesNotContain("id", moderatedSite.getId());
@@ -177,9 +175,9 @@ public class FunctionalCasesTests extends RestTest
restClient.assertStatusCodeIs(HttpStatus.CREATED);
taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite);
workflow.approveSiteMembershipRequest(adminUserModel.getUsername(), adminUserModel.getPassword(), taskModel.getId(), true, "Accept");
workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept");
restClient.authenticateUser(adminUserModel).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite);
restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername());
@@ -195,10 +193,10 @@ public class FunctionalCasesTests extends RestTest
description = "Add a file and check that activity is included in person activities")
public void addFileThenGetPersonActivities() throws Exception
{
FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2);
file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN);
activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2);
activities.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("siteId", siteModel.getId())
.and().entriesListContains("siteId", publicSite.getId())
.and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-added")
.and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion());
}
@@ -213,11 +211,11 @@ public class FunctionalCasesTests extends RestTest
description = "Add a comment to a file and check that activity is included in person activities")
public void addCommentThenGetPersonActivities() throws Exception
{
FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(user).withCoreAPI().usingResource(file).addComment("new comment");
activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3);
file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN);
restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment");
activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(3);
activities.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("siteId", siteModel.getId())
.and().entriesListContains("siteId", publicSite.getId())
.and().entriesListContains("activityType", "org.alfresco.comments.comment-created")
.and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion());
}
@@ -232,12 +230,223 @@ public class FunctionalCasesTests extends RestTest
description = "Add a file, delete it and check that activity is included in person activities")
public void addFileDeleteItThenGetPersonActivities() throws Exception
{
FileModel file = dataContent.usingUser(user).usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
dataContent.usingUser(user).usingResource(file).deleteContent();
activities = restClient.authenticateUser(user).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2);
file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN);
dataContent.usingUser(manager).usingResource(file).deleteContent();
activities = restClient.authenticateUser(manager).withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2);
activities.assertThat().entriesListIsNotEmpty()
.and().entriesListContains("siteId", siteModel.getId())
.and().entriesListContains("siteId", publicSite.getId())
.and().entriesListContains("activityType", "org.alfresco.documentlibrary.file-deleted")
.and().entriesListContains("activitySummary.objectId", file.getNodeRefWithoutVersion());
}
/**
* 1. Post one comment
* 2. Get comment details
* 3. Update comment
* 4. Get again comment details
* 5. Delete comment
*/
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS },
executionType = ExecutionType.REGRESSION,
description = "Add comment to a file, then get comment details. Update it and check that get comment returns updated details. Delete comment then check that file has no comments.")
public void addUpdateDeleteCommentThenGetCommentDetails() throws Exception
{
file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN);
RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment");
restClient.assertStatusCodeIs(HttpStatus.CREATED);
RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments.assertThat().entriesListContains("content", newComment.getContent());
RestCommentModel updatedComment = restClient.withCoreAPI().usingResource(file).updateComment(newComment, "updated comment");
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments.assertThat().entriesListContains("content", updatedComment.getContent()).assertThat().entriesListDoesNotContain("content", newComment.getContent());
restClient.withCoreAPI().usingResource(file).deleteComment(updatedComment);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments.assertThat().entriesListIsEmpty();
}
/**
* 1. Post one comment
* 2. Delete comment
* 3. Post the same comment again
*/
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS },
executionType = ExecutionType.REGRESSION,
description = "Add a comment to a file, delete it, then added the same comment again.")
public void checkThatADeletedCommentCanBePostedAgain() throws Exception
{
file = dataContent.usingUser(manager).usingSite(publicSite).createContent(DocumentType.TEXT_PLAIN);
RestCommentModel newComment = restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment");
restClient.assertStatusCodeIs(HttpStatus.CREATED);
RestCommentModelsCollection fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments.assertThat().entriesListContains("content", newComment.getContent());
restClient.withCoreAPI().usingResource(file).deleteComment(newComment);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments.assertThat().entriesListIsEmpty();
restClient.authenticateUser(manager).withCoreAPI().usingResource(file).addComment("new comment");
restClient.assertStatusCodeIs(HttpStatus.CREATED);
fileComments = restClient.withCoreAPI().usingResource(file).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
fileComments.assertThat().entriesListContains("content", newComment.getContent());
}
/**
* Scenario:
* 1. join an user to a site
* 2. Check action is included in person activities list
*
* @throws Exception
*/
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
@TestRail(section = {TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION,
description = "Create an user, join the user to a site and check that activity is included in person activities")
public void joinUserToSiteThenGetPersonActivities() throws Exception
{
UserModel userJoinSite = dataUser.createRandomTestUser();
restClient.authenticateUser(userJoinSite).withCoreAPI().usingMe().addSiteMembershipRequest(publicSite);
activities = restClient.withCoreAPI().usingAuthUser().getPersonActivitiesUntilEntriesCountIs(2);
activities.assertThat().entriesListIsNotEmpty().and()
.entriesListContains("siteId", publicSite.getId()).and()
.entriesListContains("activityType", "org.alfresco.site.user-joined").and()
.entriesListContains("activitySummary.memberPersonId", userJoinSite.getUsername());
}
/**
* Scenario:
* 1. Add user to private site
* 2. Remove user from private site
* 3. User creates membership request to the same private site
*/
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.REGRESSION, description = "Verify membership request by user after it was removed from site gets status code 404")
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
public void userCanNotCreateMembershipRequestIfItWasRemovedFromPrivateSite() throws Exception
{
UserModel newMember = dataUser.createRandomTestUser();
newMember.setUserRole(UserRole.SiteCollaborator);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newMember)
.assertThat().field("id").is(newMember.getUsername());
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(privateSite);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(privateSite);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), privateSite.getTitle()));
}
/**
* Scenario:
* 1. User creates membership request to moderated site
* 2. Accept membership request
* 3. Remove user from moderated site
* 4. Add user on moderated site
*/
@TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE },
executionType = ExecutionType.REGRESSION, description = "Verify user can be added back after if was removed from site")
@Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.FULL })
public void userCanBeAddedAfterItWasRemovedFromSite() throws Exception
{
UserModel newMember = dataUser.createRandomTestUser();
newMember.setUserRole(UserRole.SiteCollaborator);
restClient.authenticateUser(newMember).withCoreAPI().usingMe().addSiteMembershipRequest(moderatedSite);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
RestTaskModel taskModel = restClient.authenticateUser(newMember).withWorkflowAPI().getTasks().getTaskModelByDescription(moderatedSite);
workflow.approveSiteMembershipRequest(adminUser.getUsername(), adminUser.getPassword(), taskModel.getId(), true, "Accept");
restClient.authenticateUser(adminUser).withCoreAPI().usingUser(newMember).deleteSiteMember(moderatedSite);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newMember.getUsername());
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSite).addPerson(newMember)
.assertThat().field("id").is(newMember.getUsername());
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.withCoreAPI().usingSite(moderatedSite).getSiteMembers().assertThat().entriesListContains("id", newMember.getUsername());
}
/**
* Scenario:
* 1. Create document in site
* 2. Add comment
* 3. Delete document
* 4. Get comments and check if the above comment was deleted
*/
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS },
executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document was also removed after deleting the document")
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
public void checkTheCommentOfADocumentThatWasDeletedDoesNotExist() throws Exception
{
FileModel document = dataContent.usingSite(publicSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
String newContent = "This is a new comment added by " + adminUser.getUsername();
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).addComment(newContent)
.assertThat().field("content").isNotEmpty()
.and().field("content").is(newContent);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
dataContent.usingUser(adminUser).usingResource(document).deleteContent();
restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError().containsSummary((String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, document.getNodeRefWithoutVersion())));
}
/**
* Scenario:
* 1. Add user to private site
* 2. Add comment to a document of private site
* 3. Remove user from site
* 4. Get comments and check if the above comment was deleted
*/
@TestRail(section = { TestGroup.REST_API, TestGroup.COMMENTS },
executionType = ExecutionType.REGRESSION, description = "Check that a comment of a document from a private site is not deleted after user is removed")
@Test(groups = { TestGroup.REST_API, TestGroup.COMMENTS, TestGroup.FULL })
public void checkThatCommentIsNotDeletedWhenPrivateSiteMemberIsRemoved() throws Exception
{
UserModel newUser = dataUser.createRandomTestUser();
newUser.setUserRole(UserRole.SiteManager);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).addPerson(newUser);
FileModel document = dataContent.usingSite(privateSite).usingUser(adminUser).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
String newContent = "This is a new comment added by " + newUser.getUsername();
restClient.authenticateUser(newUser).withCoreAPI().usingResource(document).addComment(newContent)
.assertThat().field("content").isNotEmpty()
.and().field("content").is(newContent);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(adminUser).withCoreAPI().usingSite(privateSite).deleteSiteMember(newUser);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withCoreAPI().usingSite(privateSite).getSiteMembers().assertThat().entriesListDoesNotContain("id", newUser.getUsername());
RestCommentModelsCollection comments = restClient.authenticateUser(adminUser).withCoreAPI().usingResource(document).getNodeComments();
restClient.assertStatusCodeIs(HttpStatus.OK);
comments.assertThat().entriesListContains("content", newContent)
.and().entriesListContains("createdBy.id", newUser.getUsername());
}
}
@@ -0,0 +1,92 @@
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);
}
}
@@ -0,0 +1,144 @@
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);
}
}
@@ -51,7 +51,7 @@ public class UpdateTagSanityTests extends RestTest
}
@TestRail(section = { TestGroup.REST_API, TestGroup.TAGS }, executionType = ExecutionType.SANITY, description = "Verify Admin user updates tags and status code is 200")
@Bug(id="MNT-16917")
@Bug(id="REPO-1828")
@Test(groups = { TestGroup.REST_API, TestGroup.TAGS, TestGroup.SANITY })
public void adminIsAbleToUpdateTags() throws JsonToModelConversionException, Exception
{
@@ -74,11 +74,14 @@ public class UpdateTagSanityTests extends RestTest
@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, TestGroup.SANITY })
public void collaboratorIsNotAbleToUpdateTag() throws JsonToModelConversionException, Exception
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);
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,
@@ -0,0 +1,267 @@
package org.alfresco.rest.workflow.processes;
import org.alfresco.dataprep.CMISUtil;
import org.alfresco.dataprep.CMISUtil.DocumentType;
import org.alfresco.rest.RestTest;
import org.alfresco.rest.exception.EmptyRestModelCollectionException;
import org.alfresco.rest.model.RestErrorModel;
import org.alfresco.rest.model.RestItemModel;
import org.alfresco.rest.model.RestItemModelsCollection;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.ProcessModel;
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 DeleteProcessItemFullTests extends RestTest
{
private FileModel document, document2;
private SiteModel siteModel;
private UserModel userWhoStartsProcess, assignee, adminUser, anotherUser, adminTenantUser, tenantUser, tenantUserAssignee, adminTenantUser2;
private ProcessModel processModel;
private RestItemModelsCollection items;
private RestItemModel processItem;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
adminUser = dataUser.getAdminUser();
userWhoStartsProcess = dataUser.createRandomTestUser();
assignee = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userWhoStartsProcess).createPublicRandomSite();
document = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
dataWorkflow.usingUser(userWhoStartsProcess).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(assignee);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Try to delete existing process item using empty processId")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemUsingEmptyProcessId() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT);
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processModel.setId("");
restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The entity with id: "))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Add a new process item, update the item and then delete.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void createUpdateDeleteProcessItem() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.MSPOWERPOINT);
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
processItem.setName("newItemName");
processItem.assertThat().field("name").is("newItemName");
restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems()
.assertThat().entriesListDoesNotContain("name", processItem.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item using any user.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemByAnyUser() throws Exception
{
anotherUser = dataUser.createRandomTestUser();
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML);
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(anotherUser).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError()
.containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId()))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId()))
.stackTraceIs(RestErrorModel.STACKTRACE);;
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item with admin.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemWithAdmin() throws Exception
{
processModel = restClient.authenticateUser(adminUser).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
document2 = dataContent.usingAdmin().usingSite(siteModel).createContent(DocumentType.HTML);
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document2);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(adminUser).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListDoesNotContain("name", processItem.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item by the user who is involved in the process.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemByUserInvolvedInTheProcess() throws Exception
{
processModel = restClient.authenticateUser(assignee).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(assignee).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListDoesNotContain("name", processItem.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item by the user who started the process.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemByUserThatStartedTheProcess() throws Exception
{
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListDoesNotContain("name", processItem.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item for a deleted process.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemsForDeletedProcess() throws Exception
{
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.withWorkflowAPI().usingProcess(processModel).deleteProcess();
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingProcess(processModel).deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND)
.assertLastError()
.containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, processModel.getId()))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item by inexistent user.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL })
public void deleteProcessItemByInexistentUser() throws Exception
{
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(UserModel.getRandomUserModel()).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED)
.assertLastError()
.containsSummary(RestErrorModel.AUTHENTICATION_FAILED)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.API_DEFAULT_ERRORKEY)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item for process without items.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL},
expectedExceptions = EmptyRestModelCollectionException.class)
public void deleteProcessItemsForProcessWithoutItems() throws Exception
{
processModel = restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI()
.addProcess("activitiAdhoc", assignee, false, CMISUtil.Priority.Normal);
items = restClient.withWorkflowAPI().usingProcess(processModel).getProcessItems();
restClient.assertStatusCodeIs(HttpStatus.OK);
items.assertThat().entriesListIsEmpty();
restClient.authenticateUser(userWhoStartsProcess).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(items.getOneRandomEntry());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item using by the admin in same network.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.FULL, TestGroup.NETWORKS })
public void deleteProcessItemByAdminSameNetwork() throws Exception
{
restClient.authenticateUser(adminUser);
adminTenantUser = UserModel.getAdminTenantUser();
restClient.usingTenant().createTenant(adminTenantUser);
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document).createNewTaskAndAssignTo(tenantUserAssignee);
processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(adminTenantUser).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.NO_CONTENT);
restClient.withWorkflowAPI().usingProcess(processModel).getProcessVariables()
.assertThat().entriesListDoesNotContain("name", processItem.getName());
}
@TestRail(section = { TestGroup.REST_API, TestGroup.PROCESSES }, executionType = ExecutionType.REGRESSION,
description = "Delete process item using by admin in other network.")
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.PROCESSES, TestGroup.CORE, TestGroup.NETWORKS })
public void deleteProcessItemByAdminInOtherNetwork() throws Exception
{
adminTenantUser = UserModel.getAdminTenantUser();
restClient.authenticateUser(adminUser).usingTenant().createTenant(adminTenantUser);
tenantUserAssignee = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenantAssignee");
tenantUser = dataUser.usingUser(adminTenantUser).createUserWithTenant("uTenant");
adminTenantUser2 = UserModel.getAdminTenantUser();
restClient.usingTenant().createTenant(adminTenantUser2);
siteModel = dataSite.usingUser(adminTenantUser).createPublicRandomSite();
dataWorkflow.usingUser(tenantUser).usingSite(siteModel).usingResource(document)
.createNewTaskAndAssignTo(tenantUserAssignee);
processModel = restClient.withWorkflowAPI().getProcesses().getOneRandomEntry().onModel();
processItem = restClient.withWorkflowAPI().usingProcess(processModel).addProcessItem(document);
restClient.assertStatusCodeIs(HttpStatus.CREATED);
restClient.authenticateUser(adminTenantUser2).withWorkflowAPI().usingProcess(processModel)
.deleteProcessItem(processItem);
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN)
.assertLastError()
.containsSummary(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.containsErrorKey(RestErrorModel.PROCESS_RUNNING_IN_ANOTHER_TENANT)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
}
@@ -19,6 +19,7 @@ import org.alfresco.utility.testrail.annotation.TestRail;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -42,7 +43,12 @@ public class GetTaskFullTests extends RestTest
userModel = dataUser.createRandomTestUser();
siteModel = dataSite.usingUser(userModel).createPublicRandomSite();
fileModel = dataContent.usingSite(siteModel).createContent(DocumentType.TEXT_PLAIN);
assigneeUser = dataUser.createRandomTestUser();
assigneeUser = dataUser.createRandomTestUser();
}
@BeforeMethod(alwaysRun=true)
public void createTask() throws Exception
{
taskModel = dataWorkflow.usingUser(userModel).usingSite(siteModel).usingResource(fileModel).createNewTaskAndAssignTo(assigneeUser);
}
@@ -10,6 +10,7 @@ import org.alfresco.rest.model.RestProcessDefinitionModel;
import org.alfresco.rest.model.RestTaskModel;
import org.alfresco.rest.model.RestVariableModelsCollection;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.ProcessModel;
import org.alfresco.utility.model.SiteModel;
import org.alfresco.utility.model.TaskModel;
import org.alfresco.utility.model.TestGroup;
@@ -517,4 +518,70 @@ public class UpdateTaskFullTestsBulk1 extends RestTest
restTaskModel = restClient.authenticateUser(anyUser).withWorkflowAPI().usingTask(taskModel).updateTask("unclaimed");
restClient.assertStatusCodeIs(HttpStatus.FORBIDDEN).assertLastError().containsSummary("Permission was denied");
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Verify user cannot delegate task with emty assignee name and response is 400")
public void updateTaskWithEmptyAssigneeValue() throws Exception
{
JsonObject inputJson = JsonBodyGenerator.defineJSON()
.add("state", "delegated")
.add("assignee", "")
.build();
restTaskModel = restClient.authenticateUser(owner)
.withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsErrorKey(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED)
.containsSummary(RestErrorModel.DELEGATING_ASSIGNEE_PROVIDED)
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Verify owner can resolve task when assignee is the owner and response is 200")
public void taskOwnerUpdateTaskResolveStateAndOwnerAssignee() throws Exception
{
JsonObject inputJson = JsonBodyGenerator.defineJSON()
.add("state", "resolved")
.add("assignee", owner.getUsername())
.build();
restTaskModel = restClient.authenticateUser(owner)
.withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson);
restClient.assertStatusCodeIs(HttpStatus.OK);
restTaskModel.assertThat().field("state").is("resolved")
.and().field("assignee").isNull();
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Verify owner cannot update task after it was deleted and response is 404")
public void updateTaskAfterItWasDeleted() throws Exception
{
ProcessModel process = new ProcessModel();
process.setId(taskModel.getProcessId());
dataWorkflow.usingUser(owner).deleteProcess(process);
restTaskModel = restClient.authenticateUser(owner)
.withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("completed");
restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
.containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY)
.containsSummary(String.format(RestErrorModel.ENTITY_WAS_NOT_FOUND, taskModel.getId()));
}
@Test(groups = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS, TestGroup.FULL })
@TestRail(section = { TestGroup.REST_API, TestGroup.WORKFLOW, TestGroup.TASKS }, executionType = ExecutionType.REGRESSION,
description = "Verify task owner cannot update task with empty input body and response is 400")
public void taskOwnerCannotUpdateTaskWithEmptyInputBody() throws Exception
{
JsonObject inputJson = JsonBodyGenerator.defineJSON().build();
restTaskModel = restClient.authenticateUser(owner)
.withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(inputJson);
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, "null"))
.containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, "null"));
}
}
@@ -251,9 +251,9 @@ public class UpdateTaskFullTestsBulk2 extends RestTest
public void updateTaskByProvidingEmptyStateValue() throws Exception
{
restTaskModel = restClient.authenticateUser(userModel).withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask(" ");
restClient.assertStatusCodeIs(HttpStatus.METHOD_NOT_ALLOWED).assertLastError()
.containsErrorKey(RestErrorModel.PUT_EMPTY_ARGUMENT)
.containsSummary(RestErrorModel.PUT_EMPTY_ARGUMENT)
restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST).assertLastError()
.containsErrorKey(String.format(RestErrorModel.TASK_INVALID_STATE, " "))
.containsSummary(String.format(RestErrorModel.TASK_INVALID_STATE, " "))
.descriptionURLIs(RestErrorModel.RESTAPIEXPLORER)
.stackTraceIs(RestErrorModel.STACKTRACE);
}
@@ -88,7 +88,17 @@ public class UpdateTaskSanityTests extends RestTest
restTaskModel = restClient.authenticateUser(userModel1).withWorkflowAPI().usingTask(taskModel).updateTask("completed");
restClient.assertStatusCodeIs(HttpStatus.OK);
restTaskModel.assertThat().field("id").is(taskModel.getId())
.and().field("description").is(taskModel.getMessage());
restTaskModel.assertThat()
.field("dueAt").isNotEmpty()
.and().field("processDefinitionId").is("activitiReviewPooled:1:12")
.and().field("processId").is(taskModel.getProcessId())
.and().field("name").is("Review Task")
.and().field("description").is(taskModel.getMessage())
.and().field("startedAt").isNotEmpty()
.and().field("id").is(taskModel.getId())
.and().field("state").is("unclaimed")
.and().field("activityDefinitionId").is("reviewTask")
.and().field("priority").is(taskModel.getPriority().getLevel())
.and().field("formResourceKey").is("wf:activitiReviewTask");
}
}