Moved packaging develop into its own directory

This commit is contained in:
Chris Shields
2020-07-21 10:44:26 +01:00
parent 66664d40de
commit cd847f8f80
627 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,645 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.data.PermissionMapping;
import org.apache.chemistry.opencmis.commons.enums.AclPropagation;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.chemistry.opencmis.commons.impl.jaxb.EnumBasicPermissions;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AclTests extends CmisTest
{
UserModel testUser, inviteUser, unauthorizedUser;
SiteModel testSite, privateSite;
FileModel testFile;
FolderModel testFolder;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
inviteUser = dataUser.createRandomTestUser();
unauthorizedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Site manager can get the acls for valid document")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS })
public void siteManagerShouldGetDocumentAcls() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.and().assertThat().hasAcls();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Site manager can get the acls for valid folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetFolderAcls() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.and().assertThat().hasAcls();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl for valid document with AclPropagation set to REPOSITORYDETERMINED")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddAclWithRepositoryDeterminedPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo();
cmisApi.usingResource(testFile).addAcl(inviteUser, UserRole.SiteContributor, AclPropagation.REPOSITORYDETERMINED)
.then().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl for valid folder with AclPropagation set to PROPAGATE")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddAclWithPropagate() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.usingResource(testFolder).addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.PROPAGATE)
.then().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl for valid folder with AclPropagation set to OBJECTONLY")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddAclWithObjectOnlyPropagation() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.usingResource(testFolder).addAcl(inviteUser, UserRole.SiteCollaborator, AclPropagation.OBJECTONLY)
.then().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl for valid folder with AclPropagation set to OBJECTONLY")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanApplyAclWithObjectOnlyPropagation() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.usingResource(testFolder).addAcl(inviteUser, UserRole.SiteCollaborator, AclPropagation.OBJECTONLY)
.then().applyAcl(inviteUser, UserRole.SiteConsumer, UserRole.SiteCollaborator, AclPropagation.OBJECTONLY)
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteConsumer)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify appply acl with invalid role that will be removed")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void applyAclWithInvalidAddedRole() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().addAcl(inviteUser, UserRole.SiteCollaborator, AclPropagation.OBJECTONLY)
.then().applyAcl(inviteUser, UserRole.SiteConsumer, UserRole.SiteManager, AclPropagation.OBJECTONLY);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Apply Acl for valid folder with AclPropagation set to PROPAGATE")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanApplyAclWithPropagate() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.PROPAGATE)
.when().applyAcl(inviteUser, UserRole.SiteManager, UserRole.SiteConsumer, AclPropagation.PROPAGATE)
.assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteManager)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl for valid folder with AclPropagation set to REPOSITORYDETERMINED")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanApplyAclWithRepositoryDeterminedPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.OBJECTONLY)
.when().applyAcl(inviteUser, UserRole.SiteManager, UserRole.SiteConsumer, AclPropagation.REPOSITORYDETERMINED)
.assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteManager)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove Acl for valid folder with AclPropagation set to REPOSITORYDETERMINED")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRemoveAclWithRepositoryDeterminedPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.OBJECTONLY)
.when().removeAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.REPOSITORYDETERMINED)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Remove Acl for valid folder with AclPropagation set to REPOSITORYDETERMINED")
@Test(groups = {TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanRemoveAclWithPropagate() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteManager, AclPropagation.OBJECTONLY)
.when().removeAcl(inviteUser, UserRole.SiteManager, AclPropagation.PROPAGATE)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteManager);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove Acl for valid folder with AclPropagation set to REPOSITORYDETERMINED")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRemoveAclWithObjectOnlyPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteContributor, AclPropagation.OBJECTONLY)
.when().removeAcl(inviteUser, UserRole.SiteContributor, AclPropagation.OBJECTONLY)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove Acl for valid folder with AclPropagation set to REPOSITORYDETERMINED")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotRemoveInvalidAcl() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteContributor, AclPropagation.OBJECTONLY)
.when().removeAcl(inviteUser, UserRole.SiteManager, AclPropagation.OBJECTONLY);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site manager can add acl with null AclPropagation")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddAclWithNullPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteContributor, null)
.then().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site manager cannot get acl for pwc document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisRuntimeException.class)
public void siteManagerCannotGetAclForPwcDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.usingPWCDocument().addAcl(inviteUser, UserRole.SiteContributor, AclPropagation.PROPAGATE)
.then().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site manager cannot get acl for invalid object")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotGetAclForInvalidObject() throws Exception
{
FolderModel folder = FolderModel.getRandomFolderModel();
folder.setCmisLocation("/" + folder.getName() + "/");
cmisApi.authenticateUser(testUser)
.usingResource(folder)
.assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl for valid document with null AclPropagation")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanApplyAclWithNullPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.OBJECTONLY)
.when().applyAcl(inviteUser, UserRole.SiteManager, UserRole.SiteConsumer, null)
.assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteManager)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl for checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisRuntimeException.class)
public void siteManagerCannotGetAclForAppliedAclForPWC() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSEXCEL);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.OBJECTONLY)
.then().checkOut().assertThat().documentIsCheckedOut()
.usingPWCDocument().applyAcl(inviteUser, UserRole.SiteManager, UserRole.SiteConsumer)
.assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteManager);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove Acl from valid folder with null AclPropagation")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRemoveAclWithNullPropagation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteContributor, AclPropagation.OBJECTONLY)
.when().removeAcl(inviteUser, UserRole.SiteContributor)
.and().assertThat().permissionIsNotSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Unauthorized user cannot remove acl")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void removeAclByUnauthorizedUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSEXCEL);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.OBJECTONLY)
.assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteConsumer)
.when().authenticateUser(unauthorizedUser)
.removeAcl(inviteUser, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Unauthorized user cannot add acl")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void addAclByUnauthorizedUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSEXCEL);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.then().authenticateUser(unauthorizedUser)
.and().addAcl(inviteUser, UserRole.SiteConsumer, AclPropagation.OBJECTONLY);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Unauthorized user cannot apply acl")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void applyAclByUnauthorizedUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSEXCEL);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile)
.and().addAcl(inviteUser, UserRole.SiteConsumer)
.when().authenticateUser(unauthorizedUser)
.and().applyAcl(inviteUser, UserRole.SiteManager, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl for checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddAclForCheckedOutDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT).and().assertThat().existsInRepo()
.and().assertThat().documentIsCheckedOut()
.then().usingResource(testFile)
.addAcl(inviteUser, UserRole.SiteContributor)
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl by user with collaborator role for document created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanAddAclForDocumentCreatedByHimself() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl by user with collaborator role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void collaboratorCannotAddAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.addAcl(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Get Acl by user with collaborator role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanGetAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFile).refreshResource()
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by user with collaborator role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void collaboratorCannotApplyAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.applyAcl(inviteUser, UserRole.SiteCollaborator, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by user with collaborator role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void collaboratorCannotRemoveAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.removeAcl(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl by user with contributor role for document created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanAddAclForDocumentCreatedByHimself() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl by user with contributor role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void contributorCannotAddAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.addAcl(inviteUser, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Get Acl by user with collaborator role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanGetAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFile).refreshResource()
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by user with contributor role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void contributorCannotApplyAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.applyAcl(inviteUser, UserRole.SiteCollaborator, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by user with contributor role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void contributorCannotRemoveAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.removeAcl(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl by user with consumer role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotAddAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.addAcl(inviteUser, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Get Acl by user with consumer role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCanGetAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile).refreshResource()
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by user with consumer role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotApplyAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.applyAcl(inviteUser, UserRole.SiteCollaborator, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by user with consumer role for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotRemoveAclForDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.removeAcl(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl by non invited user in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotAddAclInPrivateSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.addAcl(inviteUser, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Get Acl by non invited user in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetAclInPrivateSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile).refreshResource()
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl by non invited user in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotApplyAclInPrivateSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.applyAcl(inviteUser, UserRole.SiteCollaborator, UserRole.SiteContributor)
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteCollaborator)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.applyAcl(inviteUser, UserRole.SiteContributor, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove Acl by non invited user in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotRemoveAclFromPrivateSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(testFile).and().assertThat().existsInRepo()
.addAcl(inviteUser, UserRole.SiteContributor)
.and().assertThat().permissionIsSetForUser(inviteUser, UserRole.SiteContributor)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.removeAcl(inviteUser, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Add Acl for valid document with PermissionMapping")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddAclWithPermissionMapping() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().addAcl(inviteUser, PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT)
.assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_WRITE.value())
.then().addAcl(inviteUser, PermissionMapping.CAN_DELETE_OBJECT)
.and().assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_ALL.value());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply Acl for valid document with PermissionMapping")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanApplyAclWithPermissionMapping() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().addAcl(inviteUser, PermissionMapping.CAN_DELETE_OBJECT)
.and().assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_ALL.value())
.then().applyAcl(inviteUser, PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT, PermissionMapping.CAN_DELETE_OBJECT)
.and().assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_WRITE.value())
.and().assertThat().permissionIsNotSetForUser(inviteUser, EnumBasicPermissions.CMIS_ALL.value());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove Acl for valid document with PermissionMapping")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRemoveAclWithPermissionMapping() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().addAcl(inviteUser, PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT)
.assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_WRITE.value())
.then().addAcl(inviteUser, PermissionMapping.CAN_DELETE_OBJECT)
.and().assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_ALL.value())
.then().removeAcl(inviteUser, PermissionMapping.CAN_DELETE_OBJECT)
.and().assertThat().permissionIsNotSetForUser(inviteUser, EnumBasicPermissions.CMIS_ALL.value());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Remove invalid Acl(that was not set) for valid document with PermissionMapping")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class,
expectedExceptionsMessageRegExp="No matching ACE found to remove!*")
public void siteManagerCannotRemoveInvalidAclWithPermissionMapping() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().addAcl(inviteUser, PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT)
.assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_WRITE.value())
.then().removeAcl(inviteUser, PermissionMapping.CAN_CHECKIN_DOCUMENT);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Apply invalid Acl(that was not set) for valid document with PermissionMapping")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class,
expectedExceptionsMessageRegExp="No matching ACE found to remove!*")
public void siteManagerCannotApplyInvalidAclWithPermissionMapping() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().addAcl(inviteUser, PermissionMapping.CAN_DELETE_OBJECT)
.and().assertThat().permissionIsSetForUser(inviteUser, EnumBasicPermissions.CMIS_ALL.value())
.then().applyAcl(inviteUser, PermissionMapping.CAN_UPDATE_PROPERTIES_OBJECT, PermissionMapping.CAN_CREATE_FOLDER_FOLDER);
}
}

View File

@@ -0,0 +1,222 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/28/2016.
*/
public class AddObjectToFolderTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FolderModel destinationFolder;
FileModel sourceFile;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
destinationFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(destinationFolder)
.assertThat().existsInRepo();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to add document object to folder with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldAddFileToFolder() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo()
.and().assertThat().objectIdIs(sourceFile.getNodeRef());
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to add folder object to folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisInvalidArgumentException.class,
expectedExceptionsMessageRegExp="Object is not a document!*")
public void siteManagerShouldNotAddFolderToFolder() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel folderToAdd = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(folderToAdd).assertThat().existsInRepo()
.then().addDocumentToFolder(folderToAdd, true);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to add file a document object in more than one folder in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerShouldNotAddInvalidFileToFolder() throws Exception
{
FileModel randomFile = FileModel.getRandomFileModel(FileType.HTML);
randomFile.setCmisLocation("/" + randomFile.getName() + "/");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.usingResource(randomFile)
.addDocumentToFolder(destinationFolder, true);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to add folder object to folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerShouldNotAddInvalidFolderToFolder() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel randomFolder = FolderModel.getRandomFolderModel();
randomFolder.setCmisLocation("/" + randomFolder.getName() + "/");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().addDocumentToFolder(randomFolder, true);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to add PWC document to folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldAddPWCFileToFolder() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.usingPWCDocument().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo()
.and().assertThat().documentIsCheckedOut();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to add document object to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanAddDocumentWithVersionsToFolderWithTrueAllVersions() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().update("first content").update("second content")
.and().assertThat().documentHasVersion(1.2)
.then().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo()
.and().assertThat().documentHasVersion(1.2);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to add document object to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisInvalidArgumentException.class,
expectedExceptionsMessageRegExp="Only allVersions=true supported!*")
public void siteManagerCannotAddDocumentToFolderWithFalseAllVersions() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().update("update content")
.and().assertThat().documentHasVersion(1.1)
.then().addDocumentToFolder(destinationFolder, false);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to add document object to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanAddFileToFolderCreatedByHimself() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo()
.and().assertThat().objectIdIs(sourceFile.getNodeRef());
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to add document object created by manager to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanAddFileToFolderCreatedByManager() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.then().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to add document object to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanAddFileToFolderCreatedByHimself() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo()
.and().assertThat().objectIdIs(sourceFile.getNodeRef());
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to add document object created by manager to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanAddFileToFolderCreatedByManager() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.then().addDocumentToFolder(destinationFolder, true)
.and().assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer is able to add document object created by manager to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCanAddFileToFolderCreatedByManager() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.then().addDocumentToFolder(destinationFolder, true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to delete parent folder with multiple children in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotDeleteFolderTreeInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
destinationFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser)
.usingSite(privateSite)
.createFolder(destinationFolder).assertThat().existsInRepo()
.createFile(sourceFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.then().addDocumentToFolder(destinationFolder, true);
}
}

View File

@@ -0,0 +1,217 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.Action;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class AllowableActionTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile, managerFile;
FolderModel testFolder, managerFolder;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
managerFolder = FolderModel.getRandomFolderModel();
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(managerFile).assertThat().existsInRepo()
.createFolder(managerFolder).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify valid document has allowable action CAN_CHECK_OUT")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyValidDocumentHasAllowableActionCanCheckOut() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.assertThat().hasAllowableActions(Action.CAN_CHECK_OUT)
.then().assertThat().isAllowableActionInList(Action.CAN_APPLY_ACL, Action.CAN_DELETE_CONTENT_STREAM, Action.CAN_GET_ALL_VERSIONS);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify valid folder has allowable action CAN_GET_CHILDREN, CAN_CREATE_FOLDER")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyValidFolderHasAllowableAction() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingResource(managerFolder)
.assertThat().hasAllowableActions(Action.CAN_GET_CHILDREN, Action.CAN_CREATE_FOLDER);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify pwc document has allowable action CAN_CHECK_IN, CAN_CANCEL_CHECK_OUT and CAN_MOVE_OBJECT")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyPWCDocumentHasAllowable() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.assertThat().existsInRepo().and().assertThat().documentIsCheckedOut()
.usingPWCDocument()
.assertThat().hasAllowableActions(Action.CAN_CHECK_IN, Action.CAN_MOVE_OBJECT, Action.CAN_CANCEL_CHECK_OUT)
.and().assertThat().isAllowableActionInList(Action.CAN_CHECK_IN, Action.CAN_GET_CONTENT_STREAM, Action.CAN_CANCEL_CHECK_OUT);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify valid folder does not have allowable action CAN_CHECK_IN, CAN_CHECK_OUT, CAN_CANCEL_CHECK_OUT")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyFolderDoesNotHaveCanCheckInAction() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingResource(managerFolder)
.assertThat().doesNotHaveAllowableActions(Action.CAN_CHECK_IN, Action.CAN_CHECK_OUT, Action.CAN_CANCEL_CHECK_OUT);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify delete document has allowable actions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void verifyDeletedDocumentHasAllowableActions() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().delete()
.and().assertThat().hasAllowableActions(Action.CAN_CHECK_IN, Action.CAN_MOVE_OBJECT, Action.CAN_CANCEL_CHECK_OUT);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify delete document has allowable actions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void verifyDeletedDocumentGetAllowableActions() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().delete()
.and().assertThat().isAllowableActionInList(Action.CAN_CHECK_IN, Action.CAN_MOVE_OBJECT, Action.CAN_CANCEL_CHECK_OUT);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify checked out document does not have allowable action CAN_CHECK_IN, CAN_CANCEL_CHECK_OUT")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyCheckedOutDocumentHasAllowable() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.assertThat().existsInRepo().and().assertThat().documentIsCheckedOut()
.usingResource(testFile)
.assertThat().hasAllowableActions(Action.CAN_GET_ALL_VERSIONS, Action.CAN_GET_CONTENT_STREAM, Action.CAN_GET_ACL, Action.CAN_GET_PROPERTIES)
.and().assertThat().doesNotHaveAllowableActions(Action.CAN_CHECK_IN, Action.CAN_CANCEL_CHECK_OUT);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor can get allowable and not allowable actions for content created by mananger")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorGetAllowableActionForContentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(managerFile)
.assertThat().hasAllowableActions(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_CONTENT_STREAM)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_CHECK_OUT, Action.CAN_CHECK_IN, Action.CAN_MOVE_OBJECT)
.assertThat().isAllowableActionInList(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_CONTENT_STREAM)
.usingResource(managerFolder)
.assertThat().hasAllowableActions(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_CREATE_FOLDER)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_DELETE_TREE, Action.CAN_MOVE_OBJECT)
.assertThat().isAllowableActionInList(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_CREATE_FOLDER);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator can get allowable and not allowable actions for content created by mananger")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorGetAllowableActionForContentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(managerFile)
.assertThat().hasAllowableActions(Action.CAN_UPDATE_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_CHECK_OUT, Action.CAN_ADD_OBJECT_TO_FOLDER)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_MOVE_OBJECT)
.assertThat().isAllowableActionInList(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_CONTENT_STREAM,
Action.CAN_UPDATE_PROPERTIES, Action.CAN_CHECK_OUT, Action.CAN_ADD_OBJECT_TO_FOLDER)
.usingResource(managerFolder)
.assertThat().hasAllowableActions(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_CREATE_FOLDER, Action.CAN_UPDATE_PROPERTIES)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_DELETE_TREE, Action.CAN_MOVE_OBJECT)
.assertThat().isAllowableActionInList(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_CREATE_FOLDER,Action.CAN_UPDATE_PROPERTIES);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer can get allowable and not allowable actions for content created by mananger")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerGetAllowableActionForContentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(managerFile)
.assertThat().hasAllowableActions(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_ALL_VERSIONS, Action.CAN_ADD_OBJECT_TO_FOLDER)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_MOVE_OBJECT, Action.CAN_CHECK_OUT)
.assertThat().isAllowableActionInList(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_ALL_VERSIONS, Action.CAN_ADD_OBJECT_TO_FOLDER)
.usingResource(managerFolder)
.assertThat().hasAllowableActions(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_GET_DESCENDANTS)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_DELETE_TREE, Action.CAN_MOVE_OBJECT)
.assertThat().isAllowableActionInList(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_GET_DESCENDANTS);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer can get allowable and not allowable actions for content created by mananger")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void nonInvitedUserCanGetAllowableActionForContentCreatedByManager() throws Exception
{
UserModel nonInvitedUser = dataUser.createRandomTestUser();
cmisApi.authenticateUser(nonInvitedUser)
.usingResource(managerFile)
.assertThat().hasAllowableActions(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_ALL_VERSIONS, Action.CAN_ADD_OBJECT_TO_FOLDER)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_MOVE_OBJECT, Action.CAN_CHECK_OUT)
.assertThat().isAllowableActionInList(Action.CAN_GET_PROPERTIES, Action.CAN_GET_ACL, Action.CAN_GET_ALL_VERSIONS, Action.CAN_ADD_OBJECT_TO_FOLDER)
.usingResource(managerFolder)
.assertThat().hasAllowableActions(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_GET_DESCENDANTS)
.assertThat().doesNotHaveAllowableActions(Action.CAN_DELETE_OBJECT, Action.CAN_DELETE_TREE, Action.CAN_MOVE_OBJECT)
.assertThat().isAllowableActionInList(Action.CAN_GET_FOLDER_PARENT, Action.CAN_GET_FOLDER_TREE, Action.CAN_GET_DESCENDANTS);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get allowable actions from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserOnPrivateSiteCannotGetAllowableActions() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
cmisApi.authenticateUser(testUser).usingSite(privateSite).createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile)
.assertThat().hasAllowableActions(Action.CAN_GET_PROPERTIES);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get allowable actions from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserOnModeratedSiteCannotGetAllowableActions() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
SiteModel moderatedSite = dataSite.usingUser(testUser).createModeratedRandomSite();
cmisApi.authenticateUser(testUser).usingSite(moderatedSite).createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile)
.assertThat().hasAllowableActions(Action.CAN_GET_PROPERTIES);
}
}

View File

@@ -0,0 +1,240 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/26/2016.
*/
public class AppendContentStreamTests extends CmisTest
{
UserModel siteManager;
SiteModel publicSite, privateSite;
FileModel testFile;
String initialContent = "initial content ";
String textToAppend = "text to append";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to append content to a not empty file in DocumentLibrary with CMIS")
public void siteManagerShouldAppendContentToNotEmptyFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is not able to append content to a non existent Document in DocumentLibrary with CMIS")
public void userShouldNotAppendContentToNonexistentFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile)
.assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().delete()
.and().assertThat().doesNotExistInRepo()
.then().update(textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to append content to an empty file with version with CMIS")
public void siteManagerCanAppendContentToEmptyFileWithVersion() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().setContent("")
.assertThat().contentIs("")
.refreshResource()
.then().update(textToAppend)
.and().assertThat().contentIs(textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to append content to an empty file with no version in DocumentLibrary with CMIS")
public void siteManagerCanAppendContentToEmptyFileWithNoVersion() throws Exception
{
FileModel emptyFile = FileModel.getRandomFileModel(FileType.HTML);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(emptyFile).assertThat().existsInRepo()
.and().assertThat().contentIs("")
.then().update(textToAppend)
.and().assertThat().contentIs(textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to append content with last chunk parameter set to FALSE with CMIS")
public void siteManagerCanAppendContentWithLastChunkSetToFalse() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().update(textToAppend, false)
.and().assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin is able to append content to a file created by other user in DocumentLibrary with CMIS")
public void adminShouldAppendContentToFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().authenticateUser(dataUser.getAdminUser()).update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to append content to a file created by other user in DocumentLibrary with CMIS")
public void siteManagerShouldAppendContentToFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to append content to a file created by self in DocumentLibrary with CMIS")
public void contributorShouldAppendContentToFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is not able to append content to a file created by other user in DocumentLibrary with CMIS")
public void contributorCannotAppendContentToFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).update(textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to append content to a file created by other user in DocumentLibrary with CMIS")
public void collaboratorShouldAppendContentToFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to append content to a file created by self in DocumentLibrary with CMIS")
public void collaboratorShouldAppendContentToFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is not able to append content to a file with CMIS")
public void consumerCannotAppendContentToFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).update(textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUpdateConflictException.class, expectedExceptionsMessageRegExp = "^.*Cannot perform operation since the node.*is locked.$")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to append content to a checked out file with CMIS")
public void managerCannotAppendContentToCheckedOutFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.when().update(textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to append content to a PWC file with CMIS")
public void managerCanAppendContentToPWCFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.usingPWCDocument().update(textToAppend)
.assertThat().contentIs(initialContent + textToAppend);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to append content to a file created in a private site with CMIS")
public void unauthorizedUserCannotAppendContentToFileFromPrivateSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, initialContent);
cmisApi.authenticateUser(siteManager)
.usingSite(privateSite).createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(initialContent)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).update(textToAppend);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is not able to append content to an invalid file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = InvalidCmisObjectException.class, expectedExceptionsMessageRegExp = "^Content at.*is not a file$")
public void userCannotAppendContentOfInvalidFile() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(testFolder).assertThat().existsInRepo()
.update(textToAppend);
}
}

View File

@@ -0,0 +1,154 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class CancelCheckOutTests extends CmisTest
{
UserModel siteManager;
SiteModel testSite;
FileModel testFile;
private String fileContent = "content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(siteManager).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify cancel check out on a pwc")
public void cancelCheckOutOnPWC() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.and().assertThat().isPrivateWorkingCopy()
.then().cancelCheckOut()
.and().assertThat().isNotPrivateWorkingCopy()
.and().assertThat().existsInRepo()
.and().assertThat().documentIsNotCheckedOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify cancel check out on a document that isn't checked out")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisRuntimeException.class)
public void cancelCheckOutOnADocumentThatIsntCheckedOut() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.and().assertThat().isNotPrivateWorkingCopy()
.then().cancelCheckOut();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify cancel check out on deleted document")
public void cancelCheckOutOnDeletedDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.then().delete().and().assertThat().doesNotExistInRepo()
.then().cancelCheckOut();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisRuntimeException.class)
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify cancel check out on a pwc twice")
public void cancelCheckOutTwice() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut().assertThat().isPrivateWorkingCopy()
.and().cancelCheckOut()
.cancelCheckOut();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that cancel check out on document created with Versioning State CHECKED OUT deletes the document")
public void cancelCheckOutOnDocWithVersioningStateCheckedOut() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.and().assertThat().existsInRepo().assertThat().documentIsCheckedOut()
.then().usingPWCDocument()
.cancelCheckOut()
.and().assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that collaborator user can cancel check out on document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanCancelCheckInDocumentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().cancelCheckOut()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.0);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that collaborator user can cancel check out on document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanCancelCheckInDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().cancelCheckOut()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.0);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that contributor user can cancel check out on document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanCancelCheckInDocumentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().cancelCheckOut()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.0);
}
}

View File

@@ -0,0 +1,329 @@
package org.alfresco.cmis;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisVersioningException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class CheckInTests extends CmisTest
{
UserModel unauthorizedUser;
UserModel siteManager;
SiteModel testSite;
FileModel testFile;
private String fileContent = "content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
unauthorizedUser = dataUser.createRandomTestUser();
siteManager = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(siteManager).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify check in document with minor version and no content")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void checkInDocumentWithMinorVersionAndNoContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify check in document with minor version and with content")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void checkInDocumentWithMinorVersionAndWithContent() throws Exception
{
String newContent = "new minor content";
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.assertThat().isPrivateWorkingCopy()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.withContent(newContent)
.checkIn()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1)
.and().assertThat().contentIs(newContent);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify check in document with major version and no content")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void checkInDocumentWithMajorVersionAndNoContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMajorVersion()
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(2.0);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify check in document with major version and with content")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void checkInDocumentWithMajorVersionAndWithContent() throws Exception
{
String newContent = "new major content";
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMajorVersion()
.withContent(newContent)
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(2.0);
Utility.sleep(100, 5000, () ->
cmisApi.assertThat().contentIs(newContent));
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in document that wasn't checked out")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisVersioningException.class)
public void checkInDocumentThatWasntCheckedOut() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().assertThat().documentIsNotCheckedOut()
.then().prepareDocumentForCheckIn()
.checkIn();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in comment for document with major version")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void getCheckInCommentForDocMajorVersion() throws Exception
{
String newContent = "new major content";
String comment = "major version comment";
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMajorVersion()
.withContent(newContent)
.withComment(comment)
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(2.0)
.and().assertThat().contentIs(newContent)
.assertThat().hasCheckInCommentLastVersion(comment);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in comments for multiple versions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void getCheckInCommentForDocWithMultipleVersions() throws Exception
{
String minorComment = "minor version comment";
String majorComment = "major version comment";
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.then().prepareDocumentForCheckIn()
.withMinorVersion()
.withContent("minor content")
.withComment(minorComment)
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.and().assertThat().hasCheckInCommentForVersion(1.1, minorComment)
.then().checkOut().prepareDocumentForCheckIn()
.withMajorVersion()
.withContent("major content")
.withComment(majorComment)
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.and().assertThat().hasCheckInCommentForVersion(2.0, majorComment);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in document with minor version and no content")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisVersioningException.class)
public void checkInDocumentTwice() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.checkIn()
.prepareDocumentForCheckIn()
.checkIn();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in document created with VersioningState checkedout")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void checkInDocumentCreatedWithVersioningStateCheckedOut() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.and().assertThat().existsInRepo().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn()
.withMinorVersion()
.withContent("minor content")
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in for deleted document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void checkInDeletedDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.then().delete().assertThat().doesNotExistInRepo()
.then().prepareDocumentForCheckIn()
.withMinorVersion()
.withContent("minor content")
.checkIn();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in document created with VersioningState checkedout")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void checkInDocumentWithProperties() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.NAME, testFile.getName() + "-edit");
properties.put("cm:title", testFile.getName() + "-title");
properties.put("cm:description", "description after checkout");
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.and().assertThat().existsInRepo().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn()
.withMinorVersion()
.withContent("minor content")
.checkIn(properties).refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1)
.and().assertThat().contentPropertyHasValue("cmis:description", "description after checkout")
.assertThat().contentPropertyHasValue("cmis:name", testFile.getName() + "-edit")
.assertThat().contentPropertyHasValue("cm:title", testFile.getName() + "-title");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check in document created with VersioningState checkedout")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class)
public void checkInDocumentWithInvalidProperties() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("cmis:fakeProp","fake-value");
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.and().assertThat().existsInRepo().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn()
.withMinorVersion()
.withContent("minor content")
.checkIn(properties).refreshResource();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that contributor user can check in document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanCheckInDocumentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that collaborator user can check in document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanCheckInDocumentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that collaborator user can check in document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanCheckInDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.and().checkOut()
.and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.1);
}
}

View File

@@ -0,0 +1,148 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class CheckOutTests extends CmisTest
{
UserModel unauthorizedUser;
UserModel siteManager;
SiteModel testSite;
FileModel testFile;
private String fileContent = "content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
unauthorizedUser = dataUser.createRandomTestUser();
siteManager = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(siteManager).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify check out valid document")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyCheckOutValidDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.then().assertThat().documentIsCheckedOut()
.and().assertThat().isPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify check out inexistent document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void verifyCheckOutInexistentDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().delete().assertThat().doesNotExistInRepo()
.then().checkOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify if PWC is created for document that is not checked out")
@Test(groups = {TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyPWCForDocThatIsNotCheckedOut() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile).assertThat().isNotPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify error when a document is checked out twice")
@Test(groups = {TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisVersioningException.class, expectedExceptionsMessageRegExp = "^Check out failed.*This node is already checked out.$")
public void checkOutDocumentTwice() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.then().checkOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify private working copy does NOT exists for a document that was deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyPWCDoesNotExistsForDeletedDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(testFile)
.and().checkOut()
.then().assertThat().documentIsCheckedOut()
.usingPWCDocument()
.delete()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(testFile)
.assertThat().isNotPrivateWorkingCopy().and().assertThat().documentIsNotCheckedOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that contributor user can NOT check out document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = { CmisUnauthorizedException.class, CmisPermissionDeniedException.class })
public void contributorCannotCheckOutDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.and().checkOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that consumer user can NOT check out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = { CmisUnauthorizedException.class, CmisPermissionDeniedException.class })
public void consumerCannotCheckOutDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.and().checkOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that unauthorized user can NOT check out document from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = { CmisUnauthorizedException.class, CmisPermissionDeniedException.class })
public void unauthorizedUserCannotCheckOutDocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(privateSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.authenticateUser(unauthorizedUser)
.and().checkOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that unauthorized user can NOT check out document from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = { CmisUnauthorizedException.class, CmisPermissionDeniedException.class })
public void unauthorizedUserCannotCheckOutDocumentModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, fileContent);
cmisApi.authenticateUser(siteManager).usingSite(moderatedSite)
.createFile(testFile)
.and().assertThat().existsInRepo()
.authenticateUser(unauthorizedUser)
.and().checkOut();
}
}

View File

@@ -0,0 +1,67 @@
package org.alfresco.cmis;
import java.lang.reflect.Method;
import org.alfresco.utility.LogFactory;
import org.alfresco.utility.data.DataContent;
import org.alfresco.utility.data.DataSite;
import org.alfresco.utility.data.DataUserAIS;
import org.alfresco.utility.network.ServerHealth;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeSuite;
@ContextConfiguration("classpath:alfresco-cmis-context.xml")
@Component
@Scope(value = "prototype")
public abstract class CmisTest extends AbstractTestNGSpringContextTests
{
private static Logger LOG = LogFactory.getLogger();
@Autowired
protected CmisWrapper cmisApi;
@Autowired
protected DataUserAIS dataUser;
@Autowired
protected DataSite dataSite;
@Autowired
protected DataContent dataContent;
@Autowired
ServerHealth serverHealth;
public String documentContent = "CMIS document content";
@BeforeSuite(alwaysRun = true)
public void checkServerHealth() throws Exception
{
super.springTestContextPrepareTestInstance();
serverHealth.assertServerIsOnline();
}
@BeforeMethod(alwaysRun = true)
public void showStartTestInfo(Method method)
{
LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName()));
}
@AfterMethod(alwaysRun = true)
public void showEndTestInfo(Method method)
{
LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName()));
}
public Integer getSolrWaitTimeInSeconds()
{
return cmisApi.cmisProperties.envProperty().getSolrWaitTimeInSeconds();
}
}

View File

@@ -0,0 +1,318 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/28/2016.
*/
public class CopyTests extends CmisTest
{
UserModel inexistentUser;
UserModel unauthorizedUser;
UserModel testUser;
UserModel contributorUser;
UserModel collaboratorUser;
UserModel consumerUser;
SiteModel testSite;
FileModel sourceFile;
FolderModel targetFolder, sourceFolder;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
unauthorizedUser = dataUser.createRandomTestUser();
testUser = dataUser.createRandomTestUser();
contributorUser = dataUser.createRandomTestUser();
collaboratorUser = dataUser.createRandomTestUser();
consumerUser = dataUser.createRandomTestUser();
inexistentUser = new UserModel("inexistent", "inexistent");
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
dataUser.addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to copy file to an existent location in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCopyFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().copyTo(targetFolder)
.and().assertThat().existsInRepo().usingResource(sourceFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to copy folder to an existent location in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCopyFolder() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
sourceFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).assertThat().existsInRepo()
.createFolder(sourceFolder).assertThat().existsInRepo()
.then().copyTo(targetFolder)
.and().assertThat().existsInRepo().usingResource(sourceFolder).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to copy file to a nonexistent location in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void siteManagerCopyFileToNonexistentTarget() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(sourceFile).assertThat().existsInRepo()
.createFolder(targetFolder).and().delete()
.then().copyTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to copy a nonexistent file in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void siteManagerCopyNonexistentSourceFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).assertThat().existsInRepo()
.createFile(sourceFile).delete()
.then().copyTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non existing user is not able to copy file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUnauthorizedException.class)
public void nonExistentUserIsNotAbleToCopyFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(inexistentUser)
.then().copyTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify non existing user is not able to copy folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUnauthorizedException.class)
public void nonExistentUserIsNotAbleToCopyFolder() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
sourceFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).assertThat().existsInRepo()
.createFolder(sourceFolder).assertThat().existsInRepo();
cmisApi.authenticateUser(inexistentUser)
.then().copyTo(targetFolder);
}
// @Bug(id="ACE-5606")
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that checked out document can be copied with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void checkedOutDocumentCanBeCopied() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().checkOut()
.and().copyTo(targetFolder).refreshResource()
.then().assertThat().existsInRepo()
.then().usingResource(sourceFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that whole folder structure can be copied with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void folderStructureCanBeCopied() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
FolderModel randomFolder = FolderModel.getRandomFolderModel();
sourceFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFolder(sourceFolder).and().assertThat().existsInRepo()
.usingResource(sourceFolder).createFolder(randomFolder)
.then().createFile(sourceFile).and().assertThat().existsInRepo()
.then().usingResource(sourceFolder)
.copyTo(targetFolder)
.and().assertThat().existsInRepo()
.assertThat().hasFiles(sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that version history of a copied document is not kept with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void versionHistoryIsNotKeptWhenCopyingFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().checkOut().refreshResource()
.prepareDocumentForCheckIn()
.withContent("First update").checkIn().refreshResource()
.and().assertThat().documentHasVersion(1.1)
.then().checkOut()
.prepareDocumentForCheckIn()
.withContent("Second update")
.withMajorVersion()
.checkIn().refreshResource()
.and().assertThat().documentHasVersion(2.0)
.then().copyTo(targetFolder)
.and().assertThat().existsInRepo()
.then().assertThat().documentHasVersion(1.0)
.and().assertThat().contentIs("Second update");
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify copy PWC document object")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void managerCopyPWCDocumentObject() throws Exception
{
sourceFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
FileModel pwcFile = cmisApi.authenticateUser(testUser).usingResource(sourceFile).checkOut().withCMISUtil().getPWCFileModel();
cmisApi.usingResource(pwcFile).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(pwcFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can copy Document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void contributorCanCopyDocument() throws Exception
{
sourceFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
cmisApi.authenticateUser(contributorUser).usingResource(sourceFile).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can copy Folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void contributorCanCopyFolder() throws Exception
{
sourceFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
cmisApi.authenticateUser(contributorUser).usingResource(sourceFolder).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can copy Document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void collaboratorCanCopyDocument() throws Exception
{
sourceFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
cmisApi.authenticateUser(collaboratorUser).usingResource(sourceFile).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can copy Folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void collaboratorCanCopyFolder() throws Exception
{
sourceFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
cmisApi.authenticateUser(collaboratorUser).usingResource(sourceFolder).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify consumer cannot copy Document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerCannotCopyDocument() throws Exception
{
sourceFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
cmisApi.authenticateUser(consumerUser).usingResource(sourceFile).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify consumer cannot copy Folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerCannotCopyFolder() throws Exception
{
sourceFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
targetFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
cmisApi.authenticateUser(consumerUser).usingResource(sourceFolder).copyTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot copy Document from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotCopyDocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
sourceFile = dataContent.usingUser(testUser).usingSite(privateSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(testUser).usingSite(privateSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFile).copyTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot copy Folder from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotCopyFolderFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
sourceFolder = dataContent.usingUser(testUser).usingSite(privateSite).createFolder();
targetFolder = dataContent.usingUser(testUser).usingSite(privateSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFolder).copyTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot copy Document from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotCopyDocumentFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(testUser).createModeratedRandomSite();
sourceFile = dataContent.usingUser(testUser).usingSite(moderatedSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(testUser).usingSite(moderatedSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFile).copyTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot copy Folder from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotCopyFolderFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(testUser).createModeratedRandomSite();
sourceFolder = dataContent.usingUser(testUser).usingSite(moderatedSite).createFolder();
targetFolder = dataContent.usingUser(testUser).usingSite(moderatedSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFolder).copyTo(targetFolder);
}
}

View File

@@ -0,0 +1,307 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/26/2016.
*/
public class CreateDocumentFromSourceTests extends CmisTest
{
SiteModel publicSite, privateSite;
UserModel siteManager;
FileModel sourceFile, newFile;
String sourceContent = "source content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor,
UserRole.SiteCollaborator, UserRole.SiteConsumer);
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, sourceContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(sourceFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to create file from source in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS })
public void siteManagerShouldCreateDocumentFromSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFileFromSource(newFile, sourceFile).and()
.refreshResource().then().assertThat().existsInRepo().and().assertThat().contentIs(sourceContent);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify inexistent user isn't able to create file from source in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisUnauthorizedException.class)
public void inexistentUserShouldNotCreateDocumentFromSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
UserModel inexistentUser = new UserModel("inexistent", "inexistent");
cmisApi.authenticateUser(inexistentUser).usingSite(publicSite).createFileFromSource(newFile, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify unauthorized user isn't able to create file from source in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class,
CmisUnauthorizedException.class })
public void unauthorizedUserShouldNotCreateDocumentFromSource() throws Exception
{
UserModel unauthorizedUser = dataUser.createRandomTestUser();
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(unauthorizedUser).usingSite(publicSite).createFileFromSource(newFile, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create document from source twice in the same location with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisContentAlreadyExistsException.class)
public void siteManagerCannotCreateDocumentFromSourceTwice() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFileFromSource(newFile, sourceFile).and().assertThat()
.existsInRepo().then().usingSite(publicSite).createFileFromSource(newFile, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create document from source with invalid source with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisObjectNotFoundException.class)
public void adminCannotCreateDocFromInvalidSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(publicSite).createFile(sourceFile).and().assertThat()
.existsInRepo().then().delete().when().usingResource(sourceFile).createFileFromSource(newFile, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create document from source with invalid characters with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisConstraintException.class)
public void siteManagerCannotCreateDocFromSourceWithInvalidChars() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel invalidCharDoc = new FileModel("/.:?|\\`\\.txt", FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFileFromSource(invalidCharDoc, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create document from source at invalid location with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisObjectNotFoundException.class)
public void adminCannotCreateDocumentAtInvalidPath() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel invalidLocation = new FolderModel("/Shared/invalidFolder");
cmisApi.authenticateUser(dataUser.getAdminUser()).usingResource(invalidLocation).createFileFromSource(newFile,
sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to create file from folder source CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = InvalidCmisObjectException.class)
public void siteManagerShouldNotCreateDocFromFolderSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel folderSource = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFolder(folderSource).then()
.createFileFromSource(newFile, folderSource);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create document from source with invalid base type id with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisContentAlreadyExistsException.class)
public void siteManagerCannotCreateDocFromSourceWithInvalidBaseTypeId() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFileFromSource(newFile, sourceFile).and().assertThat()
.existsInRepo().then().usingSite(publicSite).createFileFromSource(newFile, sourceFile, "cmis:fakeType");
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create an unnamed document from source with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteManagerCannotCreateUnnamedDocFromSource() throws Exception
{
newFile = new FileModel("");
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFileFromSource(newFile, sourceFile).then()
.usingSite(publicSite).assertThat().doesNotHaveFile(newFile);
Utility.sleep(100, 10000, () ->
{
cmisApi.usingSite(publicSite).assertThat().doesNotHaveFile(newFile);
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to create file from source added by another user with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void anotherSiteManagerShouldCreateDocumentFromSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile);
Utility.sleep(100, 10000, () ->
{
cmisApi.refreshResource().then().assertThat().existsInRepo().and().assertThat().contentIs(sourceContent);
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to create file from source added by another user with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void contributorShouldCreateDocumentFromSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile);
Utility.sleep(100, 10000, () ->
{
cmisApi.refreshResource().then().assertThat().existsInRepo().and().assertThat().contentIs(sourceContent);
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to create file from source added by another user with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void collaboratorShouldCreateDocumentFromSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile);
Utility.sleep(100, 10000, () ->
{
cmisApi.refreshResource().then().assertThat().existsInRepo().and()
.assertThat().contentIs(sourceContent);
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer is not able to create file from source with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class,
CmisUnauthorizedException.class })
public void consumerShouldNotCreateDocumentFromSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to create file from source with versioning state set to Minor with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void managerCreatesDocumentFromSourceWithVersionMinor() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile, VersioningState.MINOR);
Utility.sleep(100, 10000, () ->
{
cmisApi.refreshResource().then().assertThat().existsInRepo().and()
.assertThat().contentIs(sourceContent).and()
.assertThat().documentHasVersion(0.1).and()
.assertThat().isNotLatestMajorVersion();
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to create file from source with versioning state set to None with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void managerShouldCreateDocumentFromSourceWithVersionNone() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile, VersioningState.NONE);
Utility.sleep(100, 35000, () ->
{
cmisApi.refreshResource().then().assertThat().existsInRepo().and()
.assertThat().contentIs(sourceContent).and()
.assertThat().documentHasVersion(1.0);
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to create file from source with versioning state set to CHECKEDOUT with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void managerCreatesDocumentFromSourceWithVersionCHECKEDOUT() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile, VersioningState.CHECKEDOUT);
Utility.sleep(100, 35000, () ->
{
cmisApi.refreshResource().then().assertThat().existsInRepo().and()
.assertThat().contentIs(sourceContent).and()
.assertThat().documentIsCheckedOut();
});
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create document from null source with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = NullPointerException.class)
public void adminCannotCreateDocFromNullSource() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel sourceFile = null;
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(publicSite).createFileFromSource(newFile, sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager is able to create document from a source that is checked out with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void managerShouldCreateDocFromSourceThatIsCheckedOut() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, sourceContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(sourceFile).and().assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut().when().usingSite(publicSite)
.createFileFromSource(newFile, sourceFile).then().assertThat().existsInRepo().and().assertThat()
.contentIs(sourceContent).and().assertThat().documentIsNotCheckedOut();
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that manager is able to create document from a source from his private site with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void managerShouldCreateDocFromSourceFromHisPrivateSite() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, sourceContent);
cmisApi.authenticateUser(siteManager).usingSite(privateSite).createFile(sourceFile).and().assertThat().existsInRepo()
.when().usingSite(publicSite).createFileFromSource(newFile, sourceFile).then().assertThat().existsInRepo().and()
.assertThat().contentIs(sourceContent);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that an user is not able to create document from a source from a private site with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class,
CmisUnauthorizedException.class })
public void userShouldNotCreateDocFromSourceFromPrivateSite() throws Exception
{
newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, sourceContent);
cmisApi.authenticateUser(siteManager).usingSite(privateSite).createFile(sourceFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingSite(publicSite)
.createFileFromSource(newFile, sourceFile);
}
}

View File

@@ -0,0 +1,313 @@
package org.alfresco.cmis;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
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.FileType;
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.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/26/2016.
*/
public class CreateDocumentTests extends CmisTest
{
SiteModel testSite;
UserModel testUser;
UserModel inexistentUser;
FileModel testFile, adminFile;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
inexistentUser = new UserModel("inexistent", "inexistent");
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to create files in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldCreateDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify inexistent user isn't able to create files in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void inexistentUserShouldNotCreateDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(inexistentUser).usingSite(testSite).createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify unauthorized user isn't able to create files in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserShouldNotCreateDocument() throws Exception
{
UserModel unauthorizedUser = dataUser.createRandomTestUser();
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(unauthorizedUser)
.usingSite(testSite).createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify admin user is able to create files in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminShouldCreateDocument() throws Exception
{
adminFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(testSite)
.createFile(adminFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create document twice in the same location with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisContentAlreadyExistsException.class)
public void siteManagerCannotCreateDocumentTwice() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create document ending with '.'")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotCreateDocumentEndingWithPoint() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, documentContent);
testFile.setName(testFile.getName() + ".");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create document in invalid location with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void adminCannotCreateDocumentAtInvalidPath() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
FolderModel invalidLocation = new FolderModel("/Shared/invalidFolder");
cmisApi.authenticateUser(dataUser.getAdminUser()).usingResource(invalidLocation).createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create document with invalid characters in name with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void adminCannotCreateDocumentWithInvalidCharacters() throws Exception
{
FileModel invalidCharDoc = new FileModel("/.:?|\\`\\.txt", FileType.TEXT_PLAIN);
cmisApi.authenticateUser(dataUser.getAdminUser())
.usingResource(FolderModel.getSharedFolderModel())
.createFile(invalidCharDoc);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create document with invalid base type id with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotCreateDocWithInvalidObjectTypeId() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, "cmis:fakeType", VersioningState.MAJOR);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create document with cmis:folder base type id with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotCreateDocWithFolderTypeId() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, BaseTypeId.CMIS_FOLDER.value(), VersioningState.MAJOR);
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that manager user is able to create document with valid symbols in name")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanCreateDocumentWithValidSymbols() throws Exception
{
FileModel validSymbolsDoc = new FileModel("!@#$%^&", FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(validSymbolsDoc).and().assertThat().existsInRepo();
Assert.assertNotNull(cmisApi.withCMISUtil().getCmisObject(validSymbolsDoc.getCmisLocation()));
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that manager is not able to create document with empty name")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisInvalidArgumentException.class)
public void siteManagerCannotCreateDocumentWithEmptyName() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(new FileModel("", FileType.TEXT_PLAIN));
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to create file with Major versioning state")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldCreateDocumentWithMajorVersioningState() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.MAJOR).and().assertThat().existsInRepo()
.and().assertThat().documentHasVersion(1.0)
.assertThat().isLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to create file with Minor versioning state")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldCreateDocumentWithMinorVersioningState() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.HTML);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.MINOR).and().assertThat().existsInRepo()
.and().assertThat().documentHasVersion(0.1)
.assertThat().isNotLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to create file with CHECKEDOUT versioning state")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldCreateDocumentWithCheckedOutVersioningState() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT).and().assertThat().existsInRepo()
.and().assertThat().documentIsCheckedOut()
.assertThat().isPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to create file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorShouldCreateDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to create file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorShouldCreateDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is not able to create file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerShouldNotCreateDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingSite(testSite)
.createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to create file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserShouldNotCreateDocumentInSite() throws Exception
{
UserModel outsider = dataUser.createRandomTestUser();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(outsider)
.usingSite(testSite)
.createFile(testFile);
}
@Bug(id="REPO-4301")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify disabled user is not able to create file in Shared folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void disabledUserShouldNotCreateDocument() throws Exception
{
UserModel disabled = dataUser.createRandomTestUser();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(disabled);
dataUser.usingAdmin().disableUser(disabled);
cmisApi.usingShared()
.createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to create file in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserShouldNotCreateDocumentInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingSite(privateSite)
.createFile(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create document with no properties")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="Properties must not be empty!*")
public void siteManagerCannotCreateDocumentWithNoProperties() throws Exception
{
Map<String, Object> properties = new HashMap<String, Object>();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, properties, VersioningState.MAJOR);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to create file with a name containing multi byte characters.")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void managerIsAbleToCreateFileWithMultiByteName() throws Exception
{
testFile = new FileModel(RandomData.getRandomAlphanumeric() + "\ufeff\u6768\u6728\u91d1");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that manager user is not able to create document at document location")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=InvalidCmisObjectException.class)
public void siteManagerCannotCreateDocumentInDocumentLocation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().assertThat().existsInRepo()
.then().usingResource(testFile)
.createFile(testFile);
}
}

View File

@@ -0,0 +1,232 @@
package org.alfresco.cmis;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.RandomData;
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.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/26/2016
*/
public class CreateFolderTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FolderModel testFolder;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin user is able to create folder in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminShouldCreateFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to create folder in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldCreateFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify inexistent user can't create folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void inexistentUserShouldNotCreateFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(new UserModel("random user", "random password")).usingSite(testSite).createFolder(testFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify a folder with same name can't be created in the same location")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisContentAlreadyExistsException.class,
expectedExceptionsMessageRegExp="An object with this name already exists.*")
public void shouldNotCreateFolderWithSameName() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify a folder can't be created at invalid path")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class,
expectedExceptionsMessageRegExp="Object not found.*")
public void shouldNotCreateFolderAtInvalidPath() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(new SiteModel("inexitentSite")).createFolder(testFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create folder with invalid base type id with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotCreateFolderWithInvalidObjectTypeId() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder, "cmis:fakeType");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create folder with cmis:document base type id with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotCreateFolderWithDocumentTypeId() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder, BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create folder with invalid characters in name")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void adminCannotCreateFolderWithInvalidCharacters() throws Exception
{
testFolder = new FolderModel("/.:?|\\`\\.txt");
cmisApi.authenticateUser(dataUser.getAdminUser())
.usingResource(FolderModel.getSharedFolderModel())
.createFolder(testFolder);
}
@TestRail(section = {"cmis-api"}, executionType=ExecutionType.REGRESSION,
description = "Verify that admin user is not able to create folder with empty name")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisInvalidArgumentException.class,
expectedExceptionsMessageRegExp="Property cmis:name must be set!*")
public void adminCannotCreateFolderWithEmptyName() throws Exception
{
cmisApi.authenticateUser(dataUser.getAdminUser())
.usingResource(FolderModel.getSharedFolderModel())
.createFolder(new FolderModel(""));
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create folder with empty properties")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="Properties must not be empty!*")
public void siteManagerCannotCreateFolderWithNoParamenters() throws Exception
{
Map<String, Object> properties = new HashMap<String, Object>();
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFolder(testFolder, properties);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create folder with properties specific for documents")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="Property 'cmis:isLatestMajorVersion' is not valid for this type or one of the secondary types!*")
public void siteManagerCannotCreateFolderWithDocumentParamenters() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, BaseTypeId.CMIS_FOLDER.value());
properties.put(PropertyIds.NAME, testFolder.getName());
properties.put(PropertyIds.IS_LATEST_MAJOR_VERSION, "true");
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFolder(testFolder, properties);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor is able to create folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanCreateFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator is able to create folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanCreateFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer is not able to create folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotCreateFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingSite(testSite)
.createFolder(testFolder);
}
@Bug(id="REPO-4301")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify disabled user is not able to create folder in Shared location")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void disabledUserShouldNotCreateFolder() throws Exception
{
UserModel disabled = dataUser.createRandomTestUser();
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(disabled);
dataUser.usingAdmin().disableUser(disabled);
cmisApi.usingShared()
.createFolder(testFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to create folder in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserShouldNotCreateDocumentInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingSite(privateSite)
.createFolder(testFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to create folder with a name containing multi byte characters.")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void managerIsAbleToCreateFolderWithMultiByteName() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomAlphanumeric() + "\ufeff\u6768\u6728\u91d1");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo();
}
}

View File

@@ -0,0 +1,590 @@
package org.alfresco.cmis;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.DataListItemModel;
import org.alfresco.utility.model.DataListModel;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class DataListsTests extends CmisTest
{
UserModel manager;
SiteModel testSite;
DataListModel dataListModel;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
manager = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(manager).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(manager)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void adminCanCreateContactDataList() throws Exception
{
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(dataUser.getAdminUser()).usingShared()
.createDataList(dataListModel).and().assertThat().existsInRepo()
.assertThat().objectTypeIdIs("F:dl:dataList");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is able to create data list type contact")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void managerCanCreateContactDataList() throws Exception
{
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.createDataList(dataListModel).and().assertThat().existsInRepo()
.assertThat().objectTypeIdIs("F:dl:dataList")
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:contact");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void collaboratorCanCreatedIssueDataList() throws Exception
{
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createDataList(dataListModel).and().assertThat().existsInRepo()
.assertThat().objectTypeIdIs("F:dl:dataList")
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void contributorCanCreateEventAgendaDataList() throws Exception
{
dataListModel = DataListModel.getRandomDataListModel("dl:eventAgenda");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createDataList(dataListModel).and().assertThat().existsInRepo()
.assertThat().objectTypeIdIs("F:dl:dataList")
.assertThat().objectHasProperty("dl:dataListItemType", "dl:eventAgenda");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotCreateEventAgendaDataList() throws Exception
{
dataListModel = DataListModel.getRandomDataListModel("dl:eventAgenda");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingSite(testSite)
.createDataList(dataListModel).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void managerCanCreateContactDataListItem() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
itemProperties.put("dl:contactLastName", "Snow");
itemProperties.put("dl:contactEmail", "john.snow@stark.com");
itemProperties.put("dl:contactCompany", "GOT");
itemProperties.put("dl:contactJobTitle", "king");
itemProperties.put("dl:contactPhoneOffice", "1234");
itemProperties.put("dl:contactPhoneMobile", "5678");
itemProperties.put("dl:contactNotes", "you know nothing john snow");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:contact")
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void managerCanCreateIssueListItem() throws Exception
{
UserModel assignUser = dataUser.createRandomTestUser();
FileModel attachDoc1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel attachDoc2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueID", RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueStatus", "Not Started");
itemProperties.put("dl:issuePriority", "Low");
itemProperties.put("dl:issueDueDate", new Date());
itemProperties.put("dl:issueComments", "comment");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite).createFile(attachDoc1).createFile(attachDoc2)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo()
.then().attachDocument(attachDoc1)
.attachDocument(attachDoc2)
.assertThat().objectHasRelationshipWith(attachDoc1)
.assertThat().objectHasRelationshipWith(attachDoc2)
.then().assignToUser(assignUser, "R:dl:issueAssignedTo")
.assertThat().userIsAssigned(assignUser);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is able to create data list type contact")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisObjectNotFoundException.class,
expectedExceptionsMessageRegExp="Type 'D:dl:invalidItem' is unknown!*")
public void managerCannotCreateInvalidDataListItem() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:invalidItem");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:contact")
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify collaborator user is able to add issue item type for data list created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void collaboratorCanAddIssueItem() throws Exception
{
UserModel assignUser = dataUser.createRandomTestUser();
FileModel attachDoc1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel attachDoc2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueID", RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueDueDate", new Date());
itemProperties.put("dl:issueComments", "comment");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite).createFile(attachDoc1).createFile(attachDoc2)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo()
.then().attachDocument(attachDoc1)
.attachDocument(attachDoc2)
.assertThat().objectHasRelationshipWith(attachDoc1)
.assertThat().objectHasRelationshipWith(attachDoc2)
.then().assignToUser(assignUser, "R:dl:issueAssignedTo")
.assertThat().userIsAssigned(assignUser);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify contributor user is able to add issue item type for data list created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void contributorCanAddIssueItem() throws Exception
{
UserModel assignUser = dataUser.createRandomTestUser();
FileModel attachDoc1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel attachDoc2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueID", RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueStatus", "Not Started");
itemProperties.put("dl:issuePriority", "Low");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite).createFile(attachDoc1).createFile(attachDoc2)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo()
.then().attachDocument(attachDoc1)
.attachDocument(attachDoc2)
.assertThat().objectHasRelationshipWith(attachDoc1)
.assertThat().objectHasRelationshipWith(attachDoc2)
.then().assignToUser(assignUser, "R:dl:issueAssignedTo")
.assertThat().userIsAssigned(assignUser);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify consumer user is able to add issue item type for data list created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotAddIssueItem() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify non invited user is able to add issue item type for data list created by manager in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotAddIssueItemInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(manager).createPrivateRandomSite();
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(privateSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is not able to create data list item with invalid status")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisConstraintException.class)
public void managerCannotCreateTaskItemWithInvalidStatusValue() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:simpletask");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:simpletaskStatus", "invalid-status");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:simpletask");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is not able to create data list item with invalid status")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="Property 'dl:fakePriority' is not valid for this type or one of the secondary types!*")
public void managerCannotCreateTaskItemWithInvalidParameter() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:simpletask");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:fakePriority", "High");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:simpletask");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is not able to assign issue item to deleted user")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisInvalidArgumentException.class,
expectedExceptionsMessageRegExp="Property cmis:targetId must be set!*")
public void managerCannotAssignIssueItemToDeletedUser() throws Exception
{
UserModel assignUser = dataUser.createRandomTestUser();
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueID", RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueDueDate", new Date());
itemProperties.put("dl:issueComments", "comment");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
dataUser.usingAdmin().deleteUser(assignUser);
cmisApi.assignToUser(assignUser, "R:dl:issueAssignedTo").assertThat().userIsAssigned(assignUser);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is not able to assign issue item twice to same user")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisRuntimeException.class)
public void managerCannotAssignIssueItemTwice() throws Exception
{
UserModel assignUser = dataUser.createRandomTestUser();
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueID", RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueDueDate", new Date());
itemProperties.put("dl:issueComments", "comment");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
cmisApi.assignToUser(assignUser, "R:dl:issueAssignedTo").assertThat().userIsAssigned(assignUser)
.then().assignToUser(assignUser, "R:dl:issueAssignedTo");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is able to assign issue item for 2 users")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void managerCanAssignIssueItemForTwoUsers() throws Exception
{
UserModel assignUser = dataUser.createRandomTestUser();
UserModel anotherUser = dataUser.createRandomTestUser();
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:issue");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueID", RandomData.getRandomAlphanumeric());
itemProperties.put("dl:issueDueDate", new Date());
itemProperties.put("dl:issueComments", "comment");
DataListItemModel issueItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:issue");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:issue")
.then().usingResource(dataListModel)
.createDataListItem(issueItem).assertThat().existsInRepo();
cmisApi.assignToUser(assignUser, "R:dl:issueAssignedTo").assertThat().userIsAssigned(assignUser)
.then().assignToUser(anotherUser, "R:dl:issueAssignedTo");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify manager user is able to delete contact data list with no items")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void managerCanDeleteContactDataList() throws Exception
{
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:contact")
.then().delete().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify manager user is not able to create contact data list items with same name twice")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisContentAlreadyExistsException.class)
public void managerCannotCreateContactDataListWithSameNameTwice() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:contact")
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().usingResource(dataListModel)
.then().createDataListItem(contactItem);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify manager user is not able to create contact data list items at item location")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisInvalidArgumentException.class,
expectedExceptionsMessageRegExp="Parent folder is not a folder!*")
public void managerCannotCreateContactDataListItemInsideItem() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.and().assertThat().objectHasProperty("dl:dataListItemType", "dl:contact")
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().usingResource(contactItem)
.createDataListItem(contactItem);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify manager user is not able to simple delete contact data list with items")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE}, expectedExceptions=CmisConstraintException.class,
expectedExceptionsMessageRegExp="Could not delete folder with at least one child!*")
public void managerCannotSimpleDeleteContactDataListWithItems() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().usingResource(dataListModel).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify manager user is able to delete(delete tree) contact data list with items in it")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void managerCanDeleteTreeContactDataListWithItems() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().usingResource(dataListModel)
.deleteFolderTree().assertThat().doesNotExistInRepo()
.and().usingResource(contactItem).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator user is not able to delete(delete tree) contact data list with items in it created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void collaboratorCannotDeleteTreeContactDataListWithItems() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(dataListModel)
.deleteFolderTree().assertThat()
.hasFailedDeletedObject(dataListModel.getNodeRef())
.and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor user is not able to delete(delete tree) contact data list with items in it created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void contributorCannotDeleteTreeContactDataListWithItems() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(dataListModel)
.deleteFolderTree().assertThat()
.hasFailedDeletedObject(dataListModel.getNodeRef())
.and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer user is not able to delete(delete tree) contact data list with items in it created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void consumerCannotDeleteTreeContactDataListWithItems() throws Exception
{
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(dataListModel)
.deleteFolderTree().assertThat()
.hasFailedDeletedObject(dataListModel.getNodeRef())
.and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to delete(delete tree) contact data list with items in it created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.REQUIRE_SHARE})
public void nonInvitedUserCannotDeleteTreeContactDataListWithItems() throws Exception
{
UserModel nonInvited = dataUser.createRandomTestUser();
Map<String, Object> itemProperties = new HashMap<String, Object>();
itemProperties.put(PropertyIds.OBJECT_TYPE_ID, "D:dl:contact");
itemProperties.put(PropertyIds.NAME, RandomData.getRandomAlphanumeric());
itemProperties.put("dl:contactFirstName", "John");
DataListItemModel contactItem = new DataListItemModel(itemProperties);
dataListModel = DataListModel.getRandomDataListModel("dl:contact");
cmisApi.authenticateUser(manager).usingSite(testSite)
.then().createDataList(dataListModel).and().assertThat().existsInRepo()
.then().usingResource(dataListModel)
.createDataListItem(contactItem).assertThat().existsInRepo()
.then().authenticateUser(nonInvited)
.usingResource(dataListModel)
.deleteFolderTree().assertThat()
.hasFailedDeletedObject(dataListModel.getNodeRef())
.and().assertThat().existsInRepo();
}
}

View File

@@ -0,0 +1,325 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.RandomData;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/26/2016.
*/
public class DeleteAllVersionsTests extends CmisTest
{
UserModel testUser;
UserModel consumerUser;
UserModel collaboratorUser;
UserModel contributorUser;
UserModel unauthorizedUser;
SiteModel testSite;
FileModel testFile;
FolderModel testFolder;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
consumerUser = dataUser.createRandomTestUser();
collaboratorUser = dataUser.createRandomTestUser();
contributorUser = dataUser.createRandomTestUser();
unauthorizedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
dataUser.addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to delete all document versions in DocumentLibrary with CMIS")
@Test(groups = {TestGroup.SANITY, TestGroup.CMIS })
public void siteManagerDeletesAllDocumentVersions() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().update(testFile.getName())
.then().deleteAllVersions(true).and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to delete only latest document version in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerDeletesLatestDocumentVersion() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).and().update(testFile.getName())
.then().deleteAllVersions(false).and().assertThat().documentHasVersion(1.0);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete all versions of inexistent file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void siteManagerCannotDeleteAllVersionsOfInexistentFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
testFile.setCmisLocation("/fake-folder/inexistentFile.txt");
cmisApi.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete PWC file version of a file with multiple versions with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeletePWCFileWithDeleteAllVersionsTrue() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.usingResource(testFile).update("content 1")
.assertThat().documentHasVersion(1.1)
.usingResource(testFile).update("content 2")
.assertThat().documentHasVersion(1.2)
.usingResource(testFile).checkOut()
.assertThat().documentIsCheckedOut()
.usingPWCDocument().deleteAllVersions(true)
.assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo().and().assertThat().documentHasVersion(1.2);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete PWC file version of a file with multiple versions set to false with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeletePWCFileWithDeleteAllVersionsFalse() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.then().update("content 1")
.assertThat().documentHasVersion(1.1)
.then().update("content 2")
.assertThat().documentHasVersion(1.2)
.then().checkOut().refreshResource()
.assertThat().documentIsCheckedOut()
.usingPWCDocument().deleteAllVersions(false)
.assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo().and().assertThat().documentHasVersion(1.2);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete file original multiple version which is checked out with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisConstraintException.class, expectedExceptionsMessageRegExp = "^Could not delete/cancel checkout on the original checked out document$")
public void siteManagerCannotDeleteOriginalFileMultipleVersionWhenCheckedout() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.then().update("content 1")
.assertThat().documentHasVersion(1.1)
.then().update("content 2")
.assertThat().documentHasVersion(1.2)
.refreshResource().then().checkOut()
.assertThat().documentIsCheckedOut();
cmisApi.usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user is NOT able to delete a checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotDeletePWCDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).then().update("content 1")
.and().checkOut().assertThat().documentIsCheckedOut()
.when().authenticateUser(unauthorizedUser)
.usingResource(testFile).usingPWCDocument().deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager can delete object Document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeleteDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile).usingResource(testFile).update("content 1")
.usingResource(testFile).deleteAllVersions(true)
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager can delete object Folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeleteFolder() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder).usingResource(testFolder)
.deleteAllVersions(true)
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor can delete object Document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanDeleteDocumentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(contributorUser).usingSite(testSite).createFile(testFile).usingResource(testFile).update("content 1")
.deleteAllVersions(true)
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor cannot delete object Document created by site manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void contributorCannotDeleteDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).then().update("content 1")
.when().authenticateUser(contributorUser).usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor can delete object Folder created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanDeleteFolderCreatedBySelf() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(contributorUser).usingSite(testSite).createFolder(testFolder).usingResource(testFolder)
.deleteAllVersions(true)
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor cannot delete object Folder created by site manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void contributorCannotDeleteFolderCreatedByManager() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.when().authenticateUser(contributorUser)
.usingResource(testFolder).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator can delete object Document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanDeleteDocumentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(collaboratorUser).usingSite(testSite).createFile(testFile).usingResource(testFile).update("content 1")
.deleteAllVersions(true)
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator cannot delete object Document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void collaboratorCannotDeleteDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).then().update("content 1")
.when().authenticateUser(collaboratorUser)
.usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator can delete object Folder created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanDeleteFolderCreatedBySelf() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(collaboratorUser).usingSite(testSite).createFolder(testFolder).usingResource(testFolder)
.deleteAllVersions(true)
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator cannot delete object Folder created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void collaboratorCannotDeleteFolderCreatedByManager() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().authenticateUser(collaboratorUser)
.usingResource(testFolder).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer cannot delete object Document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerCannotDeleteDocumentCreated() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).update("content 1")
.when().authenticateUser(consumerUser)
.usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer cannot delete object Folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerCannotDeleteFolderCreated() throws Exception
{
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().authenticateUser(consumerUser)
.usingResource(testFolder).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot delete Document from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotDeleteDocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(testFile).then().update("content 1")
.when().authenticateUser(unauthorizedUser)
.usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot delete Folder from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotDeleteFolderFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(testUser).usingSite(privateSite).createFolder(testFolder);
cmisApi.authenticateUser(unauthorizedUser).usingResource(testFolder).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot delete Document from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotDeleteDocumentFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(testUser).createModeratedRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(moderatedSite).createFile(testFile).usingResource(testFile).update("content 1");
cmisApi.authenticateUser(unauthorizedUser).usingResource(testFile).deleteAllVersions(true);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot delete Folder from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotDeleteFolderFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(testUser).createModeratedRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
testFolder = new FolderModel(RandomData.getRandomName("Folder"));
cmisApi.authenticateUser(testUser).usingSite(moderatedSite).createFolder(testFolder);
cmisApi.authenticateUser(unauthorizedUser).usingResource(testFolder).deleteAllVersions(true);
}
}

View File

@@ -0,0 +1,236 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/27/2016.
*/
public class DeleteContentStreamTests extends CmisTest
{
UserModel siteManager;
SiteModel publicSite, privateSite;
FileModel testFile;
String content = "file content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to delete content of a not empty document in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerDeletesDocumentContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile)
.deleteContent().and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is not able to delete content of a nonexistent document in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void userCantDeleteContentFromNonexistentFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
testFile.setCmisLocation("/fake-folder/test.txt");
cmisApi.authenticateUser(siteManager)
.usingResource(testFile).deleteContent();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete content of a empty document in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeleteContentOfEmptyDocument() throws Exception
{
FileModel emptyDoc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(emptyDoc).and().assertThat().existsInRepo()
.and().assertThat().contentIs("")
.then().deleteContent().and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify nonexistent user is not able to delete content of a document with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void nonexistentUserCannotDeleteDocumentContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile)
.then().authenticateUser(UserModel.getRandomUserModel())
.usingResource(testFile).deleteContent();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete content of a not empty document with refresh set to TRUE with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeleteDocContentWithRefreshTrue() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.HTML, content);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile)
.deleteContent(true).and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete content of a not empty document with refresh set to FALSE with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeleteDocContentWithRefreshFalse() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.HTML, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile)
.deleteContent(true).and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin is able to delete content of a not empty document created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminDeletesContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(dataUser.getAdminUser())
.deleteContent().and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete content of a not empty document created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerDeletesContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.deleteContent().and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to delete content of a not empty document created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorDeletesContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.deleteContent().and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to delete content of a not empty document created by self in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorDeletesContentOfFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().deleteContent()
.and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is not able to delete content of a not empty document created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void contributorCannotDeleteContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.deleteContent();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to delete content of a not empty document created by self in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorDeletesContentOfFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().deleteContent()
.and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is not able to delete content of a not empty document in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotDeleteContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.deleteContent();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUpdateConflictException.class, expectedExceptionsMessageRegExp = "^.*Cannot perform operation since the node.*is locked.$")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to delete content of a checked out file with CMIS")
public void managerCannotDeleteContentOfCheckedOutFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.when().deleteContent();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete content of a PWC file with CMIS")
public void managerDeletesContentOfPWCFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.usingPWCDocument().deleteContent()
.assertThat().contentIs("");
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to delete content of a file created in a private site with CMIS")
public void unauthorizedUserCannotDeleteContentOfFileFromPrivateSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(siteManager)
.usingSite(privateSite).createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).deleteContent();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is not able to delete content of invalid file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = InvalidCmisObjectException.class, expectedExceptionsMessageRegExp = "^Content at.*is not a file$")
public void userShouldNotDeleteContentOfInvalidFile() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(testFolder).assertThat().existsInRepo()
.deleteContent();
}
}

View File

@@ -0,0 +1,321 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/26/2016.
*/
public class DeleteTests extends CmisTest
{
UserModel siteManager;
SiteModel publicSite, privateSite;
FolderModel testFolder;
FileModel testFile;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to delete files in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldDeleteDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).and().assertThat().existsInRepo()
.then().delete()
.and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to delete empty folders in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldDeleteEmptyFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFolder(testFolder).and().assertThat().existsInRepo()
.then().delete()
.and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete folders with chidren with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisConstraintException.class, expectedExceptionsMessageRegExp = "^Could not delete folder with at least one child!$")
public void siteManagerCannotDeleteFolderWithChildren() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFolder(testFolder)
.usingResource(testFolder).createFile(testFile)
.usingResource(testFolder).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete file with multiple versions with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeleteFileWithVersions() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFolder(testFolder)
.usingResource(testFolder).createFile(testFile)
.then().update("content 1").assertThat().documentHasVersion(1.1)
.then().update("content 2").assertThat().documentHasVersion(1.2)
.then().usingResource(testFile).delete()
.assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete file which is checked out with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisConstraintException.class, expectedExceptionsMessageRegExp = "^Could not delete/cancel checkout on the original checked out document$")
public void siteManagerCannotDeleteCheckedOutFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).usingResource(testFile).checkOut()
.assertThat().documentIsCheckedOut()
.then().delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete PWC file version with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanDeletePWCFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite).createFile(testFile).then().checkOut()
.assertThat().documentIsCheckedOut()
.usingPWCDocument().delete()
.assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete nonexistent file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void siteManagerCannotDeleteNonexistentFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
testFile.setCmisLocation("/" + testFile.getName() + "/");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.usingResource(testFile).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete nonexistent folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void siteManagerCannotDeleteNonexistentFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
testFolder.setCmisLocation("/" + testFolder.getName() + "/");
cmisApi.authenticateUser(siteManager)
.usingResource(testFolder).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete files created by another users in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldDeleteDocumentCreatedByAnotherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).delete()
.and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to delete content created by self in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorShouldDeleteContentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo()
.createFolder(testFolder).and().assertThat().existsInRepo()
.then().usingResource(testFile).delete()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(testFolder).delete()
.and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is not able to delete file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void contributorShouldNotDeleteFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFile).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is not able to delete folder created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void contributorShouldNotDeleteFolderCreatedByOtherUser() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFolder).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to delete content created by self in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorShouldDeleteContentCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo()
.createFolder(testFolder).and().assertThat().existsInRepo()
.then().usingResource(testFile).delete()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(testFolder).delete()
.and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is not able to delete file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void collaboratorShouldNotDeleteFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFile).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is not able to delete folder created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void collaboratorShouldNotDeleteFolderCreatedByOtherUser() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFolder).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is not able to delete file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerShouldNotDeleteFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is not able to delete folder created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerShouldNotDeleteFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFolder).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin is able to delete files created by another users in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminShouldDeleteDocumentCreatedByAnotherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(dataUser.getAdminUser())
.usingResource(testFile).delete()
.and().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to delete file created inside a private site with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserShouldNotDeleteFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager)
.usingSite(privateSite)
.createFile(testFile).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to delete folder created inside a private site with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserShouldNotDeleteFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager)
.usingSite(privateSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFolder).delete();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to delete content created inside a private site with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotDeleteCheckedOutFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(privateSite)
.createFile(testFile).then().checkOut()
.and().assertThat().documentIsCheckedOut()
.when().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).delete();
}
}

View File

@@ -0,0 +1,385 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.UnfileObject;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/27/2016.
*/
public class DeleteTreeTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile;
FolderModel parentTestFolder, childTestFolder;
private String content = "content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to delete parent folder with multiple children in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerDeletesFolderTree() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify exception is thrown when deleting inexistent folder tree in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerDeletesInexistentFolderTree() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).deleteFolderTree().assertThat().doesNotExistInRepo()
.deleteFolderTree();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify inexistent user is NOT able to delete parent folder with multiple children in DocumentLibrary")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void inexistentUserCannotDeleteFolderTree() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
UserModel inexistentUser = UserModel.getRandomUserModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.then().authenticateUser(inexistentUser)
.usingResource(parentTestFolder).deleteFolderTree();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete parent folder with allVersions parameter set to true")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerDeletesFolderTreeWithAllVersionsParamTrue() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).deleteFolderTree(true, UnfileObject.DELETE, true)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Only allVersions=true is supported for delete parent folder tree, allVersions=true is not supported")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisInvalidArgumentException.class})
public void deleteFolderTreeWithAllVersionsParamFalseNotSupported() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).deleteFolderTree(false, UnfileObject.DELETE, true)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
// @Bug(id="REPO-1108")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete parent folder with unfile parameter set to DELETESINGLEFILED, using checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteManagerDeletesFolderTreeWithDeleteSingleFieldWithCheckoutDoc() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder)
.usingResource(parentTestFolder)
.createFolder(childTestFolder)
.createFile(testFile).and().assertThat().existsInRepo()
.and().checkOut()
.when().usingResource(parentTestFolder).deleteFolderTree(true, UnfileObject.DELETESINGLEFILED, true)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to delete parent folder with unfile parameter set to DELETESINGLEFILED, using add object to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerDeletesFolderTreeWithDeleteSingleFieldWithAddDocToFolder1() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder)
.createFolder(childTestFolder)
.usingResource(parentTestFolder)
.createFile(testFile).and().assertThat().existsInRepo()
.usingResource(testFile).addDocumentToFolder(childTestFolder, true)
.then().usingResource(childTestFolder).deleteFolderTree(true, UnfileObject.DELETESINGLEFILED, true)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(parentTestFolder).assertThat().existsInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete parent folder with unfile parameter set to DELETESINGLEFILED, using add object to folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerDeletesFolderTreeWithDeleteSingleFieldWithAddDocToFolder2() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder)
.createFolder(childTestFolder)
.usingResource(parentTestFolder)
.createFile(testFile).and().assertThat().existsInRepo()
.usingResource(testFile).addDocumentToFolder(childTestFolder, true)
.then().usingResource(childTestFolder).deleteFolderTree(true, UnfileObject.DELETE, true)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(parentTestFolder).assertThat().existsInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Unfile-ing is not supported for delete parent folder tree")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisInvalidArgumentException.class},
expectedExceptionsMessageRegExp="Unfiling not supported!*")
public void deleteFolderTreeWithUnfileNotSupported() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).deleteFolderTree(true, UnfileObject.UNFILE, true)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
// @Bug(id="REPO-1108")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to delete parent folder with continueOnFailure parameter set to false")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerDeletesFolderTreeWithContinueOnFailureParamFalse() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder)
.usingResource(parentTestFolder)
.createFolder(childTestFolder)
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).deleteFolderTree(true, UnfileObject.DELETE, false)
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to delete parent folder with multiple children created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorDeletesOwnFolderTree() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is not able to delete parent folder with multiple children created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCannotDeleteFolderTreeCreatedByManager() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree().and().assertThat().hasFailedDeletedObject(parentTestFolder.getNodeRef())
.and().assertThat().existsInRepo()
.then().usingResource(childTestFolder).assertThat().existsInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is not able to delete parent folder with multiple children created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCannotDeleteFolderTreeCreatedByManager() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree().and().assertThat().hasFailedDeletedObject(parentTestFolder.getNodeRef())
.and().assertThat().existsInRepo()
.then().usingResource(childTestFolder).assertThat().existsInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to delete parent folder with multiple children created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorDeletesOwnFolderTree() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is not able to delete parent folder with multiple children created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCannotDeleteFolderTreeCreatedByManager() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser)
.usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree().and().assertThat().hasFailedDeletedObject(parentTestFolder.getNodeRef())
.and().assertThat().existsInRepo()
.then().usingResource(childTestFolder).assertThat().existsInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to delete parent folder with multiple children in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotDeleteFolderTreeInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser)
.usingSite(privateSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.when().usingResource(parentTestFolder)
.deleteFolderTree();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that only the parent folder is displayed in trash can after deleting it")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void checkTrashCanAfterDeletingParentFolder() throws Exception
{
parentTestFolder = FolderModel.getRandomFolderModel();
childTestFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD, content);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentTestFolder).and().assertThat().existsInRepo()
.usingResource(parentTestFolder)
.createFolder(childTestFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo()
.when().usingResource(parentTestFolder).refreshResource()
.deleteFolderTree()
.and().assertThat().doesNotExistInRepo()
.then().usingResource(childTestFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().doesNotExistInRepo();
dataUser.assertTrashCanHasContent(parentTestFolder);
dataUser.assertTrashCanDoesNotHaveContent(childTestFolder, testFile);
}
}

View File

@@ -0,0 +1,186 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetAllVersionsTests extends CmisTest
{
UserModel siteManager;
SiteModel publicSite;
FileModel testFile, managerFile;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(siteManager)
.addUsersWithRolesToSite(publicSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(managerFile).assertThat().existsInRepo()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn().checkIn()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn()
.withMajorVersion().checkIn();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get all versions for a valid document")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetAllVersionsForAValidDocument() throws Exception
{
cmisApi.authenticateUser(siteManager).usingResource(managerFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0, 1.1, 2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can not get all versions for a document that was deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisObjectNotFoundException.class)
public void siteManagerShouldNotGetAllVersionsForADeletedDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().update("content 1").update("content 2")
.assertThat().documentHasVersion(1.2).usingVersion().getAllDocumentVersions().assertHasVersions(1.0, 1.1, 1.2)
.and().delete()
.then().usingVersion().getAllDocumentVersions();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can get all versions for a document using OperationContext: OrderBy")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetAllVersionsWithOperationContextForADocument() throws Exception
{
OperationContext context = cmisApi.authenticateUser(siteManager).getSession().createOperationContext();
context.setOrderBy(PropertyIds.OBJECT_ID + " DESC");
cmisApi.authenticateUser(siteManager).usingResource(managerFile)
.usingVersion().getAllDocumentVersionsBy(context).assertHasVersionsInOrder(2.0, 1.1, 1.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager cannot get all versions for a folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=InvalidCmisObjectException.class)
public void siteManagerCannotGetAllVersionsForFolder() throws Exception
{
FolderModel folder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(folder).assertThat().existsInRepo()
.usingVersion().getAllDocumentVersions();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can get all versions for a valid checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetAllVersionsForCheckedOutDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn().checkIn()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().usingResource(testFile)
.usingVersion().getAllDocumentVersions().assertHasVersions("pwc", 1.1, 1.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can get all versions for a valid pwc document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetAllVersionsForPWCDocument() throws Exception
{
OperationContext context = cmisApi.getSession().createOperationContext();
context.setOrderBy(PropertyIds.OBJECT_ID + " DESC");
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().prepareDocumentForCheckIn().checkIn()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().usingResource(testFile).usingPWCDocument()
.usingVersion().getAllDocumentVersions().assertHasVersions(1.1, 1.0, "pwc")
.usingVersion().getAllDocumentVersionsBy(context).assertHasVersionsInOrder("pwc", 1.1, 1.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get all versions for a document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanGetAllVersionsForDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(managerFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0, 1.1, 2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get all versions for a document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanGetAllVersionsForDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(managerFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0, 1.1, 2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer can get all versions for a document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCanGetAllVersionsForDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(managerFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0, 1.1, 2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user can get all versions for a document in public site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void nonInvitedUserCannotGetAllVersionsForDocumentFromPublicSite() throws Exception
{
UserModel nonInvitedUser = dataUser.createRandomTestUser();
cmisApi.authenticateUser(nonInvitedUser)
.usingResource(managerFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0, 1.1, 2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user cannot get all versions for a document in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetAllVersionsForDocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(siteManager).usingSite(privateSite).createFile(testFile)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user cannot get all versions for a document in moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetAllVersionsForDocumentFromModeratedSite() throws Exception
{
SiteModel moderated = dataSite.usingUser(siteManager).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(siteManager).usingSite(moderated).createFile(testFile)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile)
.usingVersion().getAllDocumentVersions().assertHasVersions(1.0);
}
}

View File

@@ -0,0 +1,200 @@
package org.alfresco.cmis;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
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.chemistry.opencmis.client.api.OperationContext;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetCheckedOutDocumentsTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile;
FolderModel testFolder;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
testFolder = FolderModel.getRandomFolderModel();
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile).assertThat().existsInRepo()
.and().checkOut().assertThat().documentIsCheckedOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get checked out documents from a valid folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetCheckedOutDocumentsFromAValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser)
.usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get checked out documents from session")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetCheckedOutDocumentsFromSession() throws Exception
{
cmisApi.authenticateUser(testUser).assertThat().sessionHasCheckedOutDocument(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager CANNOT get checked out documents from inexistent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void siteManagerCannotGetCheckedOutDocumentsFromInexistentFolder() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
testFolder.setCmisLocation(Utility.buildPath("/", testFolder.getCmisLocation()));
cmisApi.authenticateUser(testUser).usingSite(testSite)
.and().usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that user is not able to get checked out documents from session created by admin in root")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void userShouldNotGetCheckedOutDocumentFromSessionCreatedByAdminInRoot() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(dataUser.getAdminUser()).usingRoot()
.createFile(testFile).assertThat().existsInRepo()
.and().checkOut()
.then().authenticateUser(testUser)
.and().assertThat().sessioDoesNotHaveCheckedOutDocument(testFile);
}
@Bug(id="MNT-17357")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get checked out documents created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorShouldGetCheckedOutDocumentsFromFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get checked out documents created by himslef")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorShouldGetCheckedOutDocumentsCreatedByHimself() throws Exception
{
FileModel collaboratorFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFolder)
.createFile(collaboratorFile).checkOut()
.usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(collaboratorFile)
.assertThat().sessionHasCheckedOutDocument(collaboratorFile);
}
@Bug(id="MNT-17357")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get checked out documents created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorShouldGetCheckedOutDocumentsFromFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get checked out documents created by himslef")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorShouldGetCheckedOutDocumentsCreatedByHimself() throws Exception
{
FileModel contributorFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFolder)
.createFile(contributorFile).checkOut()
.usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(contributorFile)
.assertThat().sessionHasCheckedOutDocument(contributorFile);
}
@Bug(id="MNT-17357")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get checked out documents created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerShouldGetCheckedOutDocumentsFromFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFolder)
.assertThat().folderHasCheckedOutDocument(testFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get checked out documents")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserShouldNotGetCheckedOutDocuments() throws Exception
{
FileModel doc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel folder = FolderModel.getRandomFolderModel();
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFolder(folder).usingResource(folder)
.createFile(doc).checkOut()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(folder)
.assertThat().folderHasCheckedOutDocument(doc);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager user is able to get checked out documents from folder with operation context")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanGetCheckedOutDocumentsFromFolderWithOperationContext() throws Exception
{
OperationContext context = cmisApi.authenticateUser(testUser).getSession().createOperationContext();
context.setOrderBy(PropertyIds.NAME + " DESC");
FileModel doc1 = new FileModel("a-file.txt", FileType.TEXT_PLAIN, documentContent);
FileModel doc2 = new FileModel("b-file.txt", FileType.TEXT_PLAIN, documentContent);
FileModel doc3 = new FileModel("c-file.txt", FileType.TEXT_PLAIN, documentContent);
FolderModel folder = FolderModel.getRandomFolderModel();
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFolder(folder).usingResource(folder)
.createFile(doc1).checkOut()
.createFile(doc2).checkOut()
.createFile(doc3)
.usingResource(folder)
.assertThat().folderHasCheckedOutDocument(context, doc2, doc1);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is able to get checked out documents from session with operation context")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanGetCheckedOutDocumentsFromSessionWithOperationContext() throws Exception
{
UserModel user = dataUser.createRandomTestUser();
OperationContext context = cmisApi.authenticateUser(user).getSession().createOperationContext();
context.setOrderBy(PropertyIds.NAME + " DESC");
FileModel doc1 = new FileModel("a-file.txt", FileType.TEXT_PLAIN, documentContent);
FileModel doc2 = new FileModel("b-file.txt", FileType.TEXT_PLAIN, documentContent);
FileModel doc3 = new FileModel("c-file.txt", FileType.TEXT_PLAIN, documentContent);
SiteModel publicSite = dataSite.usingUser(user).createPublicRandomSite();
cmisApi.authenticateUser(user).usingSite(publicSite)
.createFile(doc1).checkOut()
.createFile(doc2).checkOut()
.createFile(doc3)
.then().assertThat().sessionHasCheckedOutDocument(context, doc2, doc1);
}
}

View File

@@ -0,0 +1,203 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GetChildrenTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile;
FileModel secondFile;
FolderModel testFolder;
FolderModel subFolder;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer);
}
@BeforeMethod(alwaysRun = true)
public void generateRandomContent()
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
secondFile = FileModel.getRandomFileModel(FileType.MSEXCEL);
testFolder = FolderModel.getRandomFolderModel();
subFolder = FolderModel.getRandomFolderModel();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY, description = "Get children from valid folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void getChildrenFromValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder)
.then().usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder)
.assertThat().hasFiles(testFile, secondFile)
.assertThat().hasFolders(subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Fails to get children from folder that was previously deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS} , expectedExceptions = CmisObjectNotFoundException.class)
public void getChildrenFromDeletedFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder)
.then().usingResource(testFolder)
.assertThat().hasChildren(testFile, secondFile, subFolder)
.and().usingResource(testFolder).refreshResource().and().deleteFolderTree()
.then().usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get children for a folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorCanGetChildrenFromValidFolderCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder)
.then().usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder)
.assertThat().hasFiles(testFile, secondFile)
.assertThat().hasFolders(subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get children for a folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorCanGetChildrenFromValidFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder)
.assertThat().hasFiles(testFile, secondFile)
.assertThat().hasFolders(subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get children for a folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorCanGetChildrenFromValidFolderCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder)
.then().usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder)
.assertThat().hasFiles(testFile, secondFile)
.assertThat().hasFolders(subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get children for a folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorCanGetChildrenFromValidFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder)
.assertThat().hasFiles(testFile, secondFile)
.assertThat().hasFolders(subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer can get children for a folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerCanGetChildrenFromValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder)
.assertThat().hasFiles(testFile, secondFile)
.assertThat().hasFolders(subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non site member cannot get children for a folder from a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberCannotGetChildrenFromValidFolderFromAPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder);
cmisApi.authenticateUser(testUser)
.usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non site member cannot get children for a folder from a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberCannotGetChildrenFromValidFolderFromAModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(testUser).usingSite(moderatedSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().usingResource(testFolder)
.createFile(testFile)
.createFile(secondFile)
.createFolder(subFolder);
cmisApi.authenticateUser(testUser)
.usingResource(testFolder).assertThat().hasChildren(testFile, secondFile, subFolder);
}
}

View File

@@ -0,0 +1,200 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/27/2016.
*/
public class GetContentStreamTests extends CmisTest
{
SiteModel publicSite, privateSite;
UserModel siteManager;
FileModel testFile;
String content = "file content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get a document content in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetDocumentContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile)
.then().assertThat().existsInRepo()
.and().assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get empty document content in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetEmptyDocumentContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile)
.then().assertThat().existsInRepo().and().assertThat().contentIs("");
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to get content from checked out document with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetContentFromCheckedOutDoc() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile)
.and().assertThat().existsInRepo()
.then().checkOut()
.and().assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin is able to get document content with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminShouldGetContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(dataUser.getAdminUser())
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to get content of file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get content of file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorShouldGetContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get content of file created by self in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorShouldGetContentOfFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get content of file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorShouldGetContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get content of file created by self in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorShouldGetContentOfFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is able to get content of file created by other user in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerShouldGetContentOfFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to get content from checked out document with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldGetContentOfPWCDoc() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite).createFile(testFile)
.and().assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.usingPWCDocument().assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify unauthorized is not able to get content of file created in a private site with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void unauthorizedUserShouldNotGetFileContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
cmisApi.authenticateUser(siteManager).usingSite(privateSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is not able to get content of non existent file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisObjectNotFoundException.class)
public void userShouldNotGetContentOfNonexistentFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, content);
testFile.setCmisLocation("/" + testFile.getName() + "/");
cmisApi.authenticateUser(siteManager)
.usingResource(testFile).assertThat().contentIs(content);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify user is not able to get content of invalid file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = InvalidCmisObjectException.class, expectedExceptionsMessageRegExp = "^Content at.*is not a file$")
public void userShouldNotGetContentOfInvalidFile() throws Exception
{
FolderModel testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(testFolder).assertThat().existsInRepo()
.and().assertThat().contentIs(content);
}
}

View File

@@ -0,0 +1,194 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GetDescendantsTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile;
FileModel fileModel;
FolderModel testFolder;
FolderModel folderModel;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer);
}
@BeforeMethod(alwaysRun = true)
public void generateRandomContent()
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
fileModel = FileModel.getRandomFileModel(FileType.MSPOWERPOINT);
testFolder = FolderModel.getRandomFolderModel();
folderModel = FolderModel.getRandomFolderModel();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get descendants for valid parent folder with at least 3 children and depth set to >=1")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void getDescendantsForValidParentFolderWithAtLeast3ChildrenAndDepthGreaterThan1() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder).createFile(testFile)
.and().createFile(fileModel)
.and().createFolder(folderModel)
.then().usingResource(testFolder).assertThat().hasDescendants(1, folderModel, fileModel, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get descendants for valid parent folder with at least 3 children and depth set to -1")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void getDescendantsForValidParentFolderWithAtLeast3ChildrenAndDepthSetToMinus1() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder).createFile(testFile)
.then().createFile(fileModel)
.and().createFolder(folderModel)
.then().usingResource(testFolder).assertThat().hasDescendants(-1, folderModel, fileModel, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager CANNOT get descendants for valid parent folder with at least 2 children and depth set to 0")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisInvalidArgumentException.class})
public void getDescendantsForValidParentFolderWithAtLeast2ChildrenAndDepthSetTo0() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().usingResource(testFolder).createFile(testFile)
.and().createFolder(folderModel)
.then().usingResource(testFolder).assertThat().hasDescendants(0, folderModel, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager CANNOT get descendants for valid parent folder with at least 2 children and depth set to -2")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisInvalidArgumentException.class})
public void getDescendantsForValidParentFolderWithAtLeast2ChildrenAndDepthSetToMinus2() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().usingResource(testFolder).createFile(testFile)
.and().createFolder(folderModel)
.then().usingResource(testFolder).assertThat().hasDescendants(-2, folderModel, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager CANNOT get descendants for parent folder with at least 2 children that was previously deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void getDescendantsForDeletedParentFolderWithAtLeast2Children() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().usingResource(testFolder).createFile(testFile)
.and().createFolder(folderModel)
.and().usingResource(testFolder).deleteFolderTree()
.then().usingResource(testFolder)
.assertThat().hasDescendants(1, folderModel, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get descendants for parent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorCanGetDescendantsForValidFolderCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile)
.usingResource(testFolder).assertThat().hasDescendants(-1, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get descendants for parent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorCanGetDescendantsForValidFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFolder)
.assertThat().hasDescendants(-1, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get descendants for parent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorCanGetDescendantsForValidFolderCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile)
.usingResource(testFolder).assertThat().hasDescendants(-1, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get descendants for parent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorCanGetDescendantsForValidFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFolder)
.assertThat().hasDescendants(-1, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer can get descendants for parent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerCanGetDescendantsForValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFolder)
.assertThat().hasDescendants(-1, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that non site member cannot get descendants for a folder from a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberCannotGetDescendantsAFolderFromAPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile);
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().hasDescendants(-1, testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that non site member cannot get descendants for a folder from a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberCannotGetDescendantsAFolderFromAModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite)
.createFolder(testFolder)
.usingResource(testFolder).createFile(testFile);
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().hasDescendants(-1, testFile);
}
}

View File

@@ -0,0 +1,153 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetExtensionTests extends CmisTest
{
UserModel testUser, nonInvitedUser;
SiteModel testSite;
FileModel testFile, managerFile;
FolderModel managerFolder;
private DataUser.ListUserWithRoles usersWithRoles;
private String titledAspect = "P:cm:titled";
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerFile = FileModel.getRandomFileModel(FileType.XML, documentContent);
managerFolder = FolderModel.getRandomFolderModel();
testUser = dataUser.createRandomTestUser();
nonInvitedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(managerFile)
.createFolder(managerFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Site manager can get extensions from a valid folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanGetExtensionsForValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFolder)
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Site manager can get extensions from a valid file")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanGetExtensionsForValidFile() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site manager cannot get extensions from an invalid document - that was deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void siteManagerCannotGetExtensionsForInvalidDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.then().assertThat().hasAspectExtension(titledAspect)
.and().delete()
.then().assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site manager can get extensions from checkedout document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanGetExtensionsForCheckedOutDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.MSWORD, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).checkOut()
.then().assertThat().hasAspectExtension(titledAspect)
.then().usingPWCDocument()
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site collaborator can get extensions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanGetExtensions() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(managerFolder)
.assertThat().hasAspectExtension(titledAspect)
.then().usingResource(managerFile)
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site contributor can get extensions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanGetExtensions() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(managerFolder)
.assertThat().hasAspectExtension(titledAspect)
.then().usingResource(managerFile)
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Site consumer can get extensions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCanGetExtensions() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(managerFolder)
.assertThat().hasAspectExtension(titledAspect)
.then().usingResource(managerFile)
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Non invited user can get extensions in public site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void nonInvitedUserCanGetExtensionsInPublicSite() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(managerFolder)
.assertThat().hasAspectExtension(titledAspect)
.then().usingResource(managerFile)
.assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Non invited user cannot get extensions in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetExtensionsInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
FileModel privateDoc = FileModel.getRandomFileModel(FileType.HTML, documentContent);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(privateDoc)
.then().authenticateUser(nonInvitedUser).assertThat().hasAspectExtension(titledAspect);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Non invited user cannot get extensions in moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetExtensionsInModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(testUser).createPrivateRandomSite();
FileModel moderatedDoc = FileModel.getRandomFileModel(FileType.HTML, documentContent);
cmisApi.authenticateUser(testUser).usingSite(moderatedSite)
.createFile(moderatedDoc)
.then().authenticateUser(nonInvitedUser).assertThat().hasAspectExtension(titledAspect);
}
}

View File

@@ -0,0 +1,151 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GetFolderParentTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FolderModel testFolder;
FolderModel parentFolder;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer);
}
@BeforeMethod(alwaysRun = true)
public void generateRandomContent()
{
parentFolder = FolderModel.getRandomFolderModel();
testFolder = FolderModel.getRandomFolderModel();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY, description = "Verify folder parent")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyFolderParent() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder).createFolder(FolderModel.getRandomFolderModel())
.then().assertThat().folderHasParent(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION, description = "Verify folder parent that was previously deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void verifyFolderParentThatWasDeleted() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
.and().assertThat().existsInRepo()
.and().usingResource(parentFolder).createFolder(testFolder)
.then().assertThat().folderHasParent(parentFolder)
.and().usingResource(parentFolder).deleteFolderTree()
.then().usingResource(testFolder).assertThat().folderHasParent(parentFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorVerifyFolderParentCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder).createFolder(FolderModel.getRandomFolderModel())
.then().assertThat().folderHasParent(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorVerifyFolderParentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
.and().assertThat().existsInRepo()
.and().usingResource(parentFolder).createFolder(testFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFolder)
.assertThat().folderHasParent(parentFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorVerifyFolderParentCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder).createFolder(FolderModel.getRandomFolderModel())
.then().assertThat().folderHasParent(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorVerifyFolderParentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
.and().assertThat().existsInRepo()
.and().usingResource(parentFolder).createFolder(testFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFolder)
.assertThat().folderHasParent(parentFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer can get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerVerifyFolderParent() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(parentFolder)
.and().assertThat().existsInRepo()
.and().usingResource(parentFolder).createFolder(testFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFolder)
.assertThat().folderHasParent(parentFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non site member for a private site is not able to get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberGetFolderParentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFolder(parentFolder)
.and().assertThat().existsInRepo()
.and().usingResource(parentFolder).createFolder(testFolder);
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().folderHasParent(parentFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non site member for a moderated site is not able to get folder parent")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberGetFolderParentFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite).createFolder(parentFolder)
.and().assertThat().existsInRepo()
.and().usingResource(parentFolder).createFolder(testFolder);
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().folderHasParent(parentFolder);
}
}

View File

@@ -0,0 +1,211 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GetFolderTreeTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FolderModel testFolder;
FolderModel folderModel1;
FolderModel folderModel11;
FolderModel folderModel12;
FolderModel folderModel2;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer);
}
@BeforeMethod(alwaysRun = true)
public void generateRandomContent()
{
testFolder = FolderModel.getRandomFolderModel();
folderModel1 = FolderModel.getRandomFolderModel();
folderModel11 = FolderModel.getRandomFolderModel();
folderModel12 = FolderModel.getRandomFolderModel();
folderModel2 = FolderModel.getRandomFolderModel();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get folder tree for valid parent folder with at least 2 children" +
" folders and depth set to 1")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void getFolderTreeForValidParentFolderWithAtLeast2ChildrenFoldersAndDepthGreaterThan1() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder)
.and().createFolder(folderModel1)
.and().createFolder(folderModel2)
.then().usingResource(testFolder).assertThat().hasFolderTree(1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get folder tree for valid parent folder with at least 2 children" +
" folders and depth set to -1")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void getFolderTreeForValidParentFolderWithAtLeast2ChildrenFoldersAndDepthSetToMinus1() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder)
.and().createFolder(folderModel1)
.and().usingResource(folderModel1).createFolder(folderModel2)
.then().usingResource(testFolder).assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can NOT get folder tree for valid parent folder with at least 2 children" +
" folders and depth set to 0")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisInvalidArgumentException.class})
public void getFolderTreeForValidParentFolderWithAtLeast2ChildrenFoldersAndDepthSetTo0() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder)
.and().createFolder(folderModel11)
.and().createFolder(folderModel12)
.and().usingResource(folderModel11).createFolder(folderModel2)
.then().usingResource(testFolder)
.assertThat().hasFolderTree(0, folderModel11);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can NOT get folder tree for valid parent folder with at least 2 children" +
" folders and depth set to -2")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisInvalidArgumentException.class})
public void getFolderTreeForValidParentFolderWithAtLeast2ChildrenFoldersAndDepthSetToMinus2() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder)
.and().createFolder(folderModel11)
.and().createFolder(folderModel12)
.and().usingResource(folderModel11).createFolder(folderModel2)
.then().usingResource(testFolder)
.assertThat().hasFolderTree(-2, folderModel11);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager can NOT get folder tree for parent folder with children" +
" that was previously deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void getFolderTreeForDeletedParentFolderWithChildren() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.and().usingResource(testFolder)
.and().createFolder(folderModel11)
.and().createFolder(folderModel12)
.and().usingResource(folderModel11).createFolder(folderModel2)
.and().usingResource(testFolder).deleteFolderTree()
.then().usingResource(testFolder)
.assertThat().hasFolderTree(1, folderModel11);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorCanGetFolderTreeForValidParentFolder() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2)
.usingResource(testFolder).assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator can get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorCanGetFolderTreeForValidParentFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFolder).assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorCanGetFolderTreeForValidParentFolder() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2)
.usingResource(testFolder).assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor can get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorCanGetFolderTreeForValidParentFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFolder).assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer can get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerCanGetFolderTreeForValidParentFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFolder).assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non site member of a private site cannot get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberCannotGetFolderTreeForAFolderFromAPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite)
.createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2);
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non site member of a moderated site cannot get folder tree for valid parent folder with at least 2 children folders")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={ CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void nonSiteMemberCannotGetFolderTreeForAFolderFromAModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite)
.createFolder(testFolder)
.usingResource(testFolder).createFolder(folderModel1).and().createFolder(folderModel2);
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().hasFolderTree(-1, folderModel1, folderModel2);
}
}

View File

@@ -0,0 +1,202 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetObjectOfLatestVersionTests extends CmisTest
{
UserModel testUser, nonInvitedUser;
SiteModel testSite;
FileModel testFile, managerFile;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerFile = FileModel.getRandomFileModel(FileType.HTML, documentContent);
testUser = dataUser.createRandomTestUser();
nonInvitedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(managerFile).assertThat().existsInRepo()
.then().checkOut()
.and().prepareDocumentForCheckIn().withMajorVersion().checkIn()
.then().checkOut()
.and().prepareDocumentForCheckIn().withMinorVersion().checkIn();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to get last major version for document checked in with minor version")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetLastMajorVersionForDocumentCheckedInWithMajorVersion() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to get last minor version for document checked in with major version")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldGetLastMinorVersionForDocumentCheckedInWithMajorVersion() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.usingVersion().assertLatestMinorVersionIs(2.1);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to get last major version for document that was already deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void siteManagerCannotGetLastMajorVersionForInexistentDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().prepareDocumentForCheckIn().withMajorVersion().checkIn()
.then().usingVersion().assertLatestMajorVersionIs(2.0)
.and().delete()
.then().usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to get last major version for document that was checked out")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanGetLastMajorVersionForCheckedOutDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.and().checkOut()
.and().prepareDocumentForCheckIn().withMajorVersion().checkIn()
.usingVersion().assertLatestMajorVersionIs(2.0)
.checkOut()
.then().usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to get last minor version for document created with minor VersioningState")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanGetLastMinorVersionForDocumentWithMinorVersioningState() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.MINOR).and().assertThat().existsInRepo()
.then().usingVersion().assertLatestMinorVersionIs(0.1);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to get last major version for document created with minor VersioningState")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class,
expectedExceptionsMessageRegExp="There is no major version!*")
public void siteManagerCannotGetLastMajorVersionForDocumentWithMinorVersioningState() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.MINOR).and().assertThat().existsInRepo()
.then().usingVersion().assertLatestMajorVersionIs(0.1);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to get last minor version for document created with checked out VersioningState")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanGetLastVersionForDocumentWithCheckedOutVersioningState() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT).and().assertThat().existsInRepo()
.then().usingVersion().assertLatestMinorVersionIs(1.0)
.usingVersion().assertLatestMajorVersionIs(1.0)
.then().usingPWCDocument()
.usingVersion().assertLatestMajorVersionIs(1.0)
.usingVersion().assertLatestMinorVersionIs(1.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get last versions for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanGetLastVersionsForDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(managerFile)
.usingVersion().assertLatestMinorVersionIs(2.1)
.usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to get last versions for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanGetLastVersionsForDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(managerFile)
.usingVersion().assertLatestMinorVersionIs(2.1)
.usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer is able to get last versions for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCanGetLastVersionsForDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(managerFile)
.usingVersion().assertLatestMinorVersionIs(2.1)
.usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is able to get last versions for document created in public site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void nonInvitedUserCanGetLastVersionsForDocumentInPublicSite() throws Exception
{
cmisApi.authenticateUser(nonInvitedUser)
.usingResource(managerFile)
.usingVersion().assertLatestMinorVersionIs(2.1)
.usingVersion().assertLatestMajorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get last versions for document from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetLastVersionsForDocumentCreatedByManagerInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.createPrivateRandomSite();
FileModel privateDoc = FileModel.getRandomFileModel(FileType.XML, documentContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingSite(privateSite)
.createFile(privateDoc)
.then().checkOut()
.and().prepareDocumentForCheckIn().withMajorVersion().checkIn()
.authenticateUser(nonInvitedUser).usingVersion().assertLatestMinorVersionIs(2.0);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get last versions for document from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotGetLastVersionsForDocumentCreatedByManagerInModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.createModeratedRandomSite();
FileModel moderatedDoc = FileModel.getRandomFileModel(FileType.XML, documentContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingSite(moderatedSite)
.createFile(moderatedDoc)
.then().checkOut()
.and().prepareDocumentForCheckIn().withMajorVersion().checkIn()
.authenticateUser(nonInvitedUser).usingVersion().assertLatestMinorVersionIs(2.0);
}
}

View File

@@ -0,0 +1,191 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetObjectTypeTests extends CmisTest
{
UserModel siteManager;
SiteModel testSite;
FolderModel testFolder;
FileModel testFile;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(siteManager).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer);
testFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.createFile(testFile).and().assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.SANITY,
description = "Verify CMIS folder type")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyCmisFolderType() throws Exception
{
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.usingResource(testFolder)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.SANITY,
description = "Verify CMIS document type")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyCmisDocumentType() throws Exception
{
cmisApi.authenticateUser(siteManager).usingSite(testSite)
.usingResource(testFile)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify CMIS folder type of folder that was deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void verifyCmisFolderTypeOfDeletedFolder() throws Exception
{
FolderModel folderModel = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFolder(folderModel)
.usingResource(folderModel).delete()
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify CMIS document type of file that was deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void verifyCmisDocumentTypeOfDeletedDocument() throws Exception
{
FileModel fileModel = FileModel.getRandomFileModel(FileType.MSWORD);
cmisApi.authenticateUser(siteManager).usingSite(testSite).createFile(fileModel)
.usingResource(fileModel).delete()
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Site contributor verifies CMIS document type")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorVerifiesCmisDocumentType() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFile)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Site contributor verifies CMIS folder type")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorVerifiesCmisFolderType() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFolder)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Site collaborator verifies CMIS document type")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorVerifiesCmisDocumentType() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFile)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Site collaborator verifies CMIS folder type")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorVerifiesCmisFolderType() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFolder)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Site consumer verifies CMIS document type")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerVerifiesCmisDocumentType() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFile)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Site consumer verifies CMIS folder type")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerVerifiesCmisFolderType() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFolder)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Non site member is not able to verify CMIS document type for a document from a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotVerifyCmisObjectTypeForADocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FileModel privateSiteFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFile(privateSiteFile);
cmisApi.authenticateUser(siteManager).usingResource(privateSiteFile)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Non site member is not able to verify CMIS document type for a folder from a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotVerifyCmisFolderTypeForAFolderFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
FolderModel privateSiteFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFolder(privateSiteFolder);
cmisApi.authenticateUser(siteManager).usingResource(privateSiteFolder)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Non site member is not able to verify CMIS document type for a document from a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotVerifyCmisObjectTypeForADocumentFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
FileModel moderatedSiteFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite).createFile(moderatedSiteFile);
cmisApi.authenticateUser(siteManager).usingResource(moderatedSiteFile)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_DOCUMENT.value());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Non site member is not able to verify CMIS document type for a folder from a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotVerifyCmisObjectTypeForAFolderFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
FolderModel moderatedSiteFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite).createFolder(moderatedSiteFolder);
cmisApi.authenticateUser(siteManager).usingResource(moderatedSiteFolder)
.assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
}

View File

@@ -0,0 +1,263 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 10/5/2016.
*/
public class GetParentsTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FolderModel testFolder, parentFolder;
FileModel testFile;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteCollaborator, UserRole.SiteContributor, UserRole.SiteConsumer);
}
@BeforeMethod(alwaysRun = true)
public void generateRandomContent()
{
parentFolder = FolderModel.getRandomFolderModel();
testFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.MSWORD);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get file parents with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerGetsFileParents() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).and().assertThat().existsInRepo()
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFile(testFile).and().assertThat().existsInRepo()
.addDocumentToFolder(testFolder, true).and().assertThat().existsInRepo()
.then().assertThat().hasParents(testFolder.getName(), parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get folder parents with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerGetsFolderParents() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo()
.then().assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to get parents for an inexistent folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void siteManagerCannotGetInexistentFolderParents() throws Exception
{
FolderModel inexistentFolder = FolderModel.getRandomFolderModel();
inexistentFolder.setCmisLocation("/" + inexistentFolder.getName() + "/");
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.and().usingResource(inexistentFolder).assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorGetsFolderParentsCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo()
.then().assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorGetsFileParentsCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFile(testFile).and().assertThat().existsInRepo()
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorGetsFolderParentsCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFolder)
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorGetsFileParentsCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo()
.usingResource(testFolder).createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFile)
.assertThat().hasParents(testFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorGetsFolderParentsCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo()
.then().assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorGetsFileParentsCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFile(testFile).and().assertThat().existsInRepo()
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorGetsFolderParentsCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFolder)
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorGetsFileParentsCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo()
.usingResource(testFolder).createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFile)
.assertThat().hasParents(testFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerGetsFolderParents() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFolder)
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteConsumerGetsFileParents() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo()
.usingResource(testFolder).createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFile)
.assertThat().hasParents(testFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non site member for a private site is not able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberGetsFolderParentsFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non site member for a private site is not able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberGetsFileParentsFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFile)
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non site member for a moderated site is not able to get folder parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberGetsFolderParentsFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFolder)
.assertThat().hasParents(parentFolder.getName());
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non site member for a moderated site is not able to get file parents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberGetsFileParentsFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite)
.createFolder(parentFolder).and().assertThat().existsInRepo()
.usingResource(parentFolder).createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFile)
.assertThat().hasParents(parentFolder.getName());
}
}

View File

@@ -0,0 +1,266 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.*;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GetPropertiesTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile;
FolderModel testFolder;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(testSite, UserRole.SiteManager, UserRole.SiteCollaborator,
UserRole.SiteContributor, UserRole.SiteConsumer);
}
@BeforeMethod(alwaysRun = true)
public void generateRandomContent()
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
testFolder = FolderModel.getRandomFolderModel();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify secondaryObjectTypeIds property for valid document")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifySecondaryObjectTypeIdsPropertyForValidDocument() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.SANITY,
description = "Verify secondaryObjectTypeIds property for valid folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifySecondaryObjectTypeIdsPropertyForValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property for inexistent folder (that was previously deleted)")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
public void verifySecondaryObjectTypeIdsPropertyForInexistentFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized")
.and().usingResource(testFolder).deleteFolderTree()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property for valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void managerVerifiesSecondaryObjectTypeIdsPropertyForValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingSite(testSite).usingResource(testFolder)
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site collaborator for valid document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorVerifiesSecondaryObjectTypeIdsPropertyForValidDocumentCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site collaborator for valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorVerifiesSecondaryObjectTypeIdsPropertyForValidFolderCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site collaborator for valid document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorVerifiesSecondaryObjectTypeIdsPropertyForValidDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFile)
.assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site collaborator for valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorVerifiesSecondaryObjectTypeIdsPropertyForValidFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(testFolder)
.assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site contributor for valid document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorVerifiesSecondaryObjectTypeIdsPropertyForValidDocumentCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site contributor for valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorVerifiesSecondaryObjectTypeIdsPropertyForValidFolderCreatedBySelf() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.then().assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site contributor for valid document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorVerifiesSecondaryObjectTypeIdsPropertyForValidDocumentCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFile)
.assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site contributor for valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorVerifiesSecondaryObjectTypeIdsPropertyForValidFolderCreatedByManager() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(testFolder)
.assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site consumer for valid document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerVerifiesSecondaryObjectTypeIdsPropertyForValidDocument() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFile)
.assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify secondaryObjectTypeIds property as site consumer for valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerVerifiesSecondaryObjectTypeIdsPropertyForValidFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(testFolder)
.assertThat().objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify that non site member cannot get secondaryObjectTypeIds property for a valid document from a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotGetSecondaryObjectTypeIdsForAValidDocumentFromAPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFile(testFile)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFile).assertThat()
.objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify that non site member cannot get secondaryObjectTypeIds property for a valid folder from a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotGetSecondaryObjectTypeIdsForAValidFolderFromAPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingAdmin().createPrivateRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFolder(testFolder)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFolder).assertThat()
.objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify that non site member cannot get secondaryObjectTypeIds property for a valid document from a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotGetSecondaryObjectTypeIdsForAValidDocumentFromAModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite).createFile(testFile)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFile).assertThat()
.objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify that non site member cannot get secondaryObjectTypeIds property for a valid folder from a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonSiteMemberCannotGetSecondaryObjectTypeIdsForAValidFolderFromAModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingAdmin().createModeratedRandomSite();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(moderatedSite).createFolder(testFolder)
.and().assertThat().existsInRepo();
cmisApi.authenticateUser(testUser).usingResource(testFolder).assertThat()
.objectHasProperty("cmis:secondaryObjectTypeIds", "Secondary Object Type Ids",
"secondaryObjectTypeIds", "cmis:secondaryObjectTypeIds", "P:cm:titled", "P:sys:localized");
}
}

View File

@@ -0,0 +1,123 @@
package org.alfresco.cmis;
import org.alfresco.utility.exception.DataPreparationException;
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.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 10/6/2016.
*/
public class GetTypeChildrenTests extends CmisTest
{
@BeforeClass(alwaysRun = true)
public void setup() throws Exception
{
cmisApi.authenticateUser(dataUser.getAdminUser());
}
/**
* Get type children for a valid type id and includePropertyDefinitions set to false
* (verify that Map<String, PropertyDefinition<?>> is empty)
*/
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify admin can get type children for BaseTypeId.CMIS_DOCUMENT and includePropertyDefinitions = false")
@Test(groups = { TestGroup.CMIS, TestGroup.SANITY })
public void getTypeChildrenWithoutPropertyDefinitions()
{
cmisApi.authenticateUser(dataUser.getAdminUser())
.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions()
.hasChildren("D:srft:facetField").propertyDefinitionIsEmpty();
}
/**
* Get type children for a valid type id and includePropertyDefinitions set to true
* (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify admin can get type children for valid type id and includePropertyDefinitions = true")
@Test(groups = { TestGroup.CMIS, TestGroup.SANITY })
public void getTypeChildrenWithPropertyDefinitions()
{
cmisApi.authenticateUser(dataUser.getAdminUser()).usingObjectType(BaseTypeId.CMIS_FOLDER.value())
.withPropertyDefinitions()
.hasChildren("F:pub:DeliveryChannel").propertyDefinitionIsNotEmpty();
cmisApi.usingObjectType(BaseTypeId.CMIS_FOLDER.value()).withPropertyDefinitions()
.doesNotHaveChildren("D:srft:facetField");
}
/**
* Get invalid type children for a valid type id and includePropertyDefinitions set to true
* (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get invalid type children for valid type id")
@Test(groups = { TestGroup.CMIS, TestGroup.REGRESSION })
public void getInvalidTypeChildrenForATypeId()
{
cmisApi.authenticateUser(dataUser.getAdminUser()).usingObjectType(BaseTypeId.CMIS_FOLDER.value())
.withPropertyDefinitions()
.doesNotHaveChildren("F:pub:invalidDeliveryChannelv");
}
/**
* Get valid type children for a invalid type id and includePropertyDefinitions set to true
* (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get valid type children for invalid type id")
@Test(groups = { TestGroup.CMIS, TestGroup.REGRESSION }, expectedExceptions = {CmisObjectNotFoundException.class},
expectedExceptionsMessageRegExp="Type 'cmis:invalidfolder' is unknown!*")
public void getValidTypeChildrenForInvalidTypeId()
{
cmisApi.authenticateUser(dataUser.getAdminUser()).usingObjectType("cmis:invalidfolder")
.withPropertyDefinitions()
.hasChildren("F:pub:DeliveryChannel").propertyDefinitionIsNotEmpty();;
}
/**
* Deleted user is not authorized to get type children for a valid type id
* (verify that Map<String, PropertyDefinition<?>> is not empty)
* @throws DataPreparationException
*/
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify deleted user is not authorized to get type children for valid type id")
@Test(groups = { TestGroup.CMIS, TestGroup.REGRESSION }, expectedExceptions = {CmisUnauthorizedException.class})
public void getTypeChildrenWithWithDeletedUser() throws DataPreparationException
{
UserModel deletedUser = dataUser.createRandomTestUser();
cmisApi.authenticateUser(deletedUser)
.usingObjectType(BaseTypeId.CMIS_FOLDER.value())
.withPropertyDefinitions()
.hasChildren("F:pub:DeliveryChannel").propertyDefinitionIsNotEmpty();
dataUser.deleteUser(deletedUser);
cmisApi.disconnect()
.usingObjectType(BaseTypeId.CMIS_FOLDER.value()).withPropertyDefinitions().doesNotHaveChildren("D:srft:facetField");
}
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify disabled user is not authorized to get type children for valid type id")
@Test(groups = { TestGroup.CMIS, TestGroup.REGRESSION }, expectedExceptions = {CmisUnauthorizedException.class})
public void getTypeChildrenWithWithDisabledUser() throws DataPreparationException
{
UserModel disabledUser = dataUser.createRandomTestUser();
cmisApi.authenticateUser(disabledUser)
.usingObjectType(BaseTypeId.CMIS_FOLDER.value())
.withPropertyDefinitions()
.hasChildren("F:pub:DeliveryChannel").propertyDefinitionIsNotEmpty();
dataUser.usingAdmin().disableUser(disabledUser);
cmisApi.disconnect()
.usingObjectType(BaseTypeId.CMIS_FOLDER.value()).withPropertyDefinitions().doesNotHaveChildren("D:srft:facetField");
}
}

View File

@@ -0,0 +1,248 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
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.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetTypeDefinitionTests extends CmisTest
{
UserModel testUser;
SiteModel publicSite, privateSite, moderatedSite;
FileModel testFile;
FolderModel testFolder;
DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(testUser).createPublicRandomSite();
privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
moderatedSite = dataSite.usingUser(testUser).createModeratedRandomSite();
cmisApi.authenticateUser(testUser);
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteContributor,
UserRole.SiteConsumer);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get Type Definition for a valid folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS })
public void siteManagerShouldGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(publicSite).createFolder(testFolder)
.and().assertThat().existsInRepo()
.then().assertThat()
.typeDefinitionIs(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager can get Type Definition for a valid document")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS })
public void siteManagerShouldGetTypeDefinitionForValidDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(publicSite).createFile(testFile)
.and().assertThat().existsInRepo()
.then().assertThat()
.typeDefinitionIs(testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager cannot get Type Definition for a deleted document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisObjectNotFoundException.class })
public void siteManagerShouldGetTypeDefinitionForDeletedDocument() throws Exception
{
FileModel deletedFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(publicSite).createFile(deletedFile)
.and().usingResource(deletedFile).delete()
.then().assertThat()
.typeDefinitionIs(deletedFile);
}
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify user that was deleted cannot get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisUnauthorizedException.class })
public void deletedUserCannotGetTypeDefinitionForValidFolder() throws Exception
{
UserModel deletedUser = dataUser.createRandomTestUser();
dataUser.usingUser(testUser).addUserToSite(deletedUser, publicSite, UserRole.SiteManager);
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(publicSite).createFolder(testFolder);
cmisApi.authenticateUser(deletedUser).usingSite(publicSite).usingResource(testFolder)
.then().assertThat()
.typeDefinitionIs(testFolder);
dataUser.deleteUser(deletedUser);
cmisApi.disconnect().assertThat().baseTypeIdIs(BaseTypeId.CMIS_FOLDER.value());
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify user that was deleted can NOT get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteManagerGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingSite(publicSite).createFolder(testFolder)
.usingResource(testFolder).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Contributor is able to get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(publicSite).createFolder(testFolder).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFolder).assertThat().typeDefinitionIs(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Collaborator is able to get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite).createFolder(testFolder)
.usingResource(testFolder).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Consumer is NOT able to get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void siteConsumerCantGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingSite(publicSite).createFolder(testFolder)
.usingResource(testFolder).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Manager is able to get Type Definition for a valid file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteManagerGetTypeDefinitionForValidFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.PDF);
cmisApi.authenticateUser(testUser).usingSite(publicSite).createFile(testFile).and().assertThat().existsInRepo();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(testFile).assertThat().typeDefinitionIs(testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Contributor is able to get Type Definition for a valid file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteContributorGetTypeDefinitionForValidFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.HTML);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite).createFile(testFile)
.usingResource(testFile).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Collaborator is able to get Type Definition for a valid file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteCollaboratorGetTypeDefinitionForValidFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.XML);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite).createFile(testFile)
.usingResource(testFile).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFile);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site Consumer is NOT able to get Type Definition for a valid file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class, CmisUnauthorizedException.class })
public void siteConsumerCantGetTypeDefinitionForValidFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.UNDEFINED);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingSite(publicSite).createFile(testFile)
.usingResource(testFile)
.and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFile);
}
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify user outside private site cannot get Type Definition for a valid file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class })
public void outsideUserPrivateSiteCantGetTypeDefinitionForValidFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.XML);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(privateSite).createFile(testFile)
.usingResource(testFile).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFile);
}
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify user outside moderated site cannot get Type Definition for a valid file")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class})
public void outsideUserModeratedSiteGetTypeDefinitionForValidFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.XML);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingSite(moderatedSite).createFile(testFile)
.usingResource(testFile)
.and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFile);
}
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify user outside private site cannot get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class })
public void outsideUserPrivateSiteCantGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.XML);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(privateSite).createFolder(testFolder)
.usingResource(testFolder).createFile(testFile)
.usingResource(testFolder).and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFolder);
}
@Bug(id="REPO-4301")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify user outside moderated site cannot get Type Definition for a valid folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = { CmisPermissionDeniedException.class})
public void outsideUserModeratedSiteGetTypeDefinitionForValidFolder() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
testFile = FileModel.getRandomFileModel(FileType.XML);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingSite(moderatedSite).createFolder(testFolder)
.usingResource(testFolder).createFile(testFile)
.usingResource(testFolder)
.and().assertThat().existsInRepo()
.then().assertThat().typeDefinitionIs(testFolder);
}
}

View File

@@ -0,0 +1,139 @@
package org.alfresco.cmis;
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.chemistry.opencmis.commons.enums.BaseTypeId;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class GetTypeDescendantsTests extends CmisTest
{
@BeforeClass(alwaysRun = true)
public void setup() throws Exception
{
cmisApi.authenticateUser(dataUser.getAdminUser());
}
/**
* Get type descendants for a valid type id and includePropertyDefinitions set to true
* and depth set to -1 (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION })
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get type descendantes for valid type id and includePropertyDefinitions = true and depth = -1")
public void adminShouldGetTypeDescendantsValidInputCase1()
{
cmisApi.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withPropertyDefinitions().hasDescendantType(-1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
/**
* Get type descendants for a valid type id and includePropertyDefinitions set to true
* and depth set to 1 (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION })
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get type descendantes for valid type id and includePropertyDefinitions = true and depth = 1")
public void adminShouldGetTypeDescendantsValidInputCase2()
{
cmisApi.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
/**
* Get type descendants for a valid type id and includePropertyDefinitions set to false
* and depth set to 1 (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION })
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get type descendants for valid type id and includePropertyDefinitions = false and depth = 1")
public void adminShouldGetTypeDescendantsValidInputCase3()
{
cmisApi.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
/**
* Get type descendantes for a valid type id and includePropertyDefinitions set to false
* and depth set to -1 (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION })
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get type descendantes for valid type id and includePropertyDefinitions = false and depth = -1")
public void adminShouldGetTypeDescendantsValidInputCase4()
{
cmisApi.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(-1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
/**
* Get type descendantes for an invalid type id and includePropertyDefinitions set to false
* and depth set to -1 (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION }, expectedExceptions = {CmisObjectNotFoundException.class},
expectedExceptionsMessageRegExp="Type 'cmis:documentfake' is unknown!*")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin cannot get type descendantes for invalid type id and includePropertyDefinitions = false and depth = -1")
public void adminCannotGetTypeDescendantsForInvalidType()
{
cmisApi.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value() +"fake")
.withoutPropertyDefinitions().hasDescendantType(-1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
/**
* Get type descendantes for a valid type id and includePropertyDefinitions set to false
* and incorrect depth set to -2 (verify that Map<String, PropertyDefinition<?>> is not empty)
*/
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION }, expectedExceptions = {CmisInvalidArgumentException.class})
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin can get type descendantes for valid type id and includePropertyDefinitions = false and incorrect depth = -2")
public void adminShouldGetTypeDescendantsValidTypeWithIncorrectDepth()
{
cmisApi.usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(-2, "D:cm:dictionaryModel", "D:trx:transferLock");
}
@Test(groups = { TestGroup.CMIS , TestGroup.SANITY })
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify random user can get type descendantes for valid type id and includePropertyDefinitions = false and depth = 1")
public void userGetTypeDescendants() throws Exception
{
UserModel user = dataUser.createRandomTestUser();
cmisApi.authenticateUser(user).usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
@Bug(id="REPO-4301")
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION }, expectedExceptions=CmisUnauthorizedException.class)
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify deleted user cannot get type descendantes for valid type id and includePropertyDefinitions = false and depth = 1")
public void deletedUserCannotGetTypeDescendants() throws Exception
{
UserModel deletedUser = dataUser.createRandomTestUser();
cmisApi.authenticateUser(deletedUser).usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
dataUser.usingAdmin().deleteUser(deletedUser);
cmisApi.disconnect().usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
@Bug(id="REPO-4301")
@Test(groups = { TestGroup.CMIS , TestGroup.REGRESSION }, expectedExceptions=CmisUnauthorizedException.class)
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify disabled user cannot get type descendantes for valid type id and includePropertyDefinitions = false and depth = 1")
public void disabledUserCannotGetTypeDescendants() throws Exception
{
UserModel disabledUser = dataUser.createRandomTestUser();
cmisApi.authenticateUser(disabledUser).usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
dataUser.usingAdmin().disableUser(disabledUser);
cmisApi.disconnect().usingObjectType(BaseTypeId.CMIS_DOCUMENT.value())
.withoutPropertyDefinitions().hasDescendantType(1, "D:cm:dictionaryModel", "D:trx:transferLock");
}
}

View File

@@ -0,0 +1,188 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.report.Bug;
import org.alfresco.utility.report.Bug.Status;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class IsLatestMajorVersionTests extends CmisTest
{
UserModel managerUser, nonInviteUser;
SiteModel testSite;
FileModel minorVersionDoc, majorVersionDoc;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
minorVersionDoc = FileModel.getRandomFileModel(FileType.XML, documentContent);
majorVersionDoc = FileModel.getRandomFileModel(FileType.XML, documentContent);
managerUser = dataUser.createRandomTestUser();
nonInviteUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(managerUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(managerUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(minorVersionDoc, VersioningState.MINOR)
.createFile(majorVersionDoc, VersioningState.MAJOR);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify is latest major version for document created with VersioningState set to major")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void verifyIsLatestMajorVersionForMajorState() throws Exception
{
cmisApi.authenticateUser(managerUser).usingResource(majorVersionDoc)
.and().assertThat().isLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify latest major version for folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions=InvalidCmisObjectException.class)
public void verifyIsLatestMajorVersionOnFolders() throws Exception
{
FolderModel folderModel = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFolder(folderModel)
.and().assertThat().isLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify is latest major version for document created with VersioningState set to minor")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyIsLatestMajorVersionForMinorState() throws Exception
{
cmisApi.authenticateUser(managerUser).usingResource(minorVersionDoc)
.and().assertThat().isNotLatestMajorVersion();
}
@Bug(id = "MNT-17961", status = Status.FIXED)
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that major version doesn't change for document created with VersioningState set to none")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void verifyMajorVersionNotChangedForNoneState() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile, VersioningState.NONE).and().assertThat().existsInRepo()
.and().assertThat().isLatestMajorVersion()
.and().checkOut().and().assertThat().documentIsCheckedOut()
.and().prepareDocumentForCheckIn()
.withMinorVersion()
.checkIn().refreshResource()
.and().assertThat().documentIsNotCheckedOut()
.then().assertThat().documentHasVersion(1.0);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify is latest major version for document created with VersioningState set to checkedout")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyIsLatestMajorVersionForCheckedOutState() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile, VersioningState.CHECKEDOUT)
.usingPWCDocument()
.assertThat().existsInRepo()
.and().assertThat().isNotLatestMajorVersion()
.and().assertThat().documentIsCheckedOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify latest major version fails for document that was deleted")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void verifyIsLatestMajorVersionFailsOnDeletedDocument() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile)
.and().assertThat().isLatestMajorVersion()
.and().delete()
.then().assertThat().isLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator can verify is latest major version for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanVerifyIsLatestMajorVersion() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(majorVersionDoc)
.usingResource(majorVersionDoc)
.and().assertThat().isLatestMajorVersion()
.then().usingResource(minorVersionDoc).assertThat().isNotLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor can verify is latest major version for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanVerifyIsLatestMajorVersion() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(majorVersionDoc)
.usingResource(majorVersionDoc)
.and().assertThat().isLatestMajorVersion()
.then().usingResource(minorVersionDoc).assertThat().isNotLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer can verify is latest major version for document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCanVerifyIsLatestMajorVersion() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(majorVersionDoc)
.usingResource(majorVersionDoc)
.and().assertThat().isLatestMajorVersion()
.then().usingResource(minorVersionDoc).assertThat().isNotLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user can verify is latest major version for document in public site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void nonInvitedUserCanVerifyIsLatestMajorVersionInPublicSite() throws Exception
{
cmisApi.authenticateUser(nonInviteUser).usingResource(majorVersionDoc)
.usingResource(majorVersionDoc)
.and().assertThat().isLatestMajorVersion()
.then().usingResource(minorVersionDoc).assertThat().isNotLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user can verify is latest major version for document in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotVerifyIsLatestMajorVersionInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite();
FileModel privateDoc = FileModel.getRandomFileModel(FileType.HTML, documentContent);
cmisApi.authenticateUser(managerUser)
.usingSite(privateSite).createFile(privateDoc)
.then().authenticateUser(nonInviteUser).usingResource(privateDoc)
.and().assertThat().isLatestMajorVersion();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user can verify is latest major version for document in moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotVerifyIsLatestMajorVersionInModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(managerUser).createPrivateRandomSite();
FileModel moderatedDoc = FileModel.getRandomFileModel(FileType.HTML, documentContent);
cmisApi.authenticateUser(managerUser)
.usingSite(moderatedSite).createFile(moderatedDoc)
.then().authenticateUser(nonInviteUser).usingResource(moderatedDoc)
.and().assertThat().isLatestMajorVersion();
}
}

View File

@@ -0,0 +1,153 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class IsPrivateWorkingCopyTests extends CmisTest
{
SiteModel testSite;
UserModel managerUser, nonInvitedUser;
FileModel checkedOutDoc, simpleDoc;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
checkedOutDoc = FileModel.getRandomFileModel(FileType.XML, documentContent);
simpleDoc = FileModel.getRandomFileModel(FileType.HTML, documentContent);
managerUser = dataUser.createRandomTestUser();
nonInvitedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(managerUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(managerUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(checkedOutDoc).and().checkOut()
.createFile(simpleDoc);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to verify if checked out document is private working copy")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanVerifyIsPrivateWorkingCopy() throws Exception
{
cmisApi.authenticateUser(managerUser).usingResource(checkedOutDoc)
.assertThat().isPrivateWorkingCopy()
.then().usingResource(simpleDoc).assertThat().isNotPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to verify if pwc document is private working copy")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanVerifyIsPrivateWorkingCopyOnPwc() throws Exception
{
cmisApi.authenticateUser(managerUser).usingResource(checkedOutDoc)
.usingPWCDocument()
.assertThat().isPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to verify if deleted document is private working copy")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotVerifyIsPrivateWorkingCopyOnDeletedDoc() throws Exception
{
FileModel deletedDoc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(deletedDoc)
.then().delete().and().assertThat().doesNotExistInRepo()
.assertThat().isPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to verify if checked out document is private working copy")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanVerifyIsPrivateWorkingCopy() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(checkedOutDoc)
.assertThat().isPrivateWorkingCopy()
.then().usingResource(simpleDoc).assertThat().isNotPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to verify if checked out document is private working copy")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanVerifyIsPrivateWorkingCopy() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(checkedOutDoc)
.assertThat().isPrivateWorkingCopy()
.then().usingResource(simpleDoc).assertThat().isNotPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is able to verify if checked out document is private working copy")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void consumerCanVerifyIsPrivateWorkingCopy() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(checkedOutDoc)
.assertThat().isPrivateWorkingCopy()
.then().usingResource(simpleDoc).assertThat().isNotPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is able to verify if checked out document is private working copy in public site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void nonInvitedUserCanVerifyIsPrivateWorkingCopyInPublicSite() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(checkedOutDoc)
.assertThat().isPrivateWorkingCopy()
.then().usingResource(simpleDoc).assertThat().isNotPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to verify if checked out document is private working copy in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotVerifyIsPrivateWorkingCopyInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite();
FileModel privateFile = FileModel.getRandomFileModel(FileType.HTML);
cmisApi.authenticateUser(managerUser).usingSite(privateSite)
.createFile(privateFile)
.then().authenticateUser(nonInvitedUser)
.assertThat().isPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to verify if checked out document is private working copy in moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotVerifyIsPrivateWorkingCopyInModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(managerUser).createPrivateRandomSite();
FileModel moderatedFile = FileModel.getRandomFileModel(FileType.HTML);
cmisApi.authenticateUser(managerUser).usingSite(moderatedSite)
.createFile(moderatedFile)
.then().authenticateUser(nonInvitedUser)
.assertThat().isPrivateWorkingCopy();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to verify if document created with CHECKEDOUT versioning state is private working copy")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void verifyIsPrivateWorkingCopyForDocumentWithCheckedOutVersioningState() throws Exception
{
FileModel checkedDoc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(checkedDoc, VersioningState.CHECKEDOUT).refreshResource()
.assertThat().isPrivateWorkingCopy();
}
}

View File

@@ -0,0 +1,357 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/28/2016.
*/
public class MoveTests extends CmisTest
{
UserModel unauthorizedUser;
UserModel siteManager;
UserModel contributorUser;
UserModel collaboratorUser;
UserModel consumerUser;
SiteModel publicSite;
FileModel sourceFile;
FolderModel targetFolder, sourceFolder;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
unauthorizedUser = dataUser.createRandomTestUser();
siteManager = dataUser.createRandomTestUser();
contributorUser = dataUser.createRandomTestUser();
collaboratorUser = dataUser.createRandomTestUser();
consumerUser = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
dataUser.addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer);
dataUser.addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator);
dataUser.addUserToSite(contributorUser, publicSite, UserRole.SiteContributor);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to move a file to an existent location in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerMovesFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().moveTo(targetFolder).and().assertThat().existsInRepo()
.usingResource(sourceFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to move file to a nonexistent location in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerMovesFileToNonExistentTarget() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(sourceFile).and().assertThat().existsInRepo()
.createFolder(targetFolder).and().delete()
.then().moveTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to move a nonexistent file in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerMovesNonExistentSourceFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().delete()
.then().moveTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to move file that has multiple versions with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldMoveFileWithMultipleVersions() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().update("first content")
.assertThat().documentHasVersion(1.1)
.update("second content")
.assertThat().documentHasVersion(1.2)
.then().moveTo(targetFolder).and().assertThat().existsInRepo()
.and().usingVersion().assertHasVersions(1.0, 1.1, 1.2)
.usingResource(sourceFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to move folder structure to an existent location in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerMovesFolderStructure() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
FolderModel sourceParentFolder = FolderModel.getRandomFolderModel();
FolderModel subFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFolder(sourceParentFolder).and().assertThat().existsInRepo()
.then().usingResource(sourceParentFolder)
.createFile(sourceFile).and().assertThat().existsInRepo()
.createFolder(subFolder).and().assertThat().existsInRepo()
.when().usingResource(sourceParentFolder)
.moveTo(targetFolder).and().assertThat().existsInRepo()
.and().assertThat().hasChildren(sourceFile, subFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify inexistent is not able to move file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void inexistentUserCannotMoveFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(UserModel.getRandomUserModel())
.moveTo(targetFolder).and().assertThat().existsInRepo()
.usingResource(sourceFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to move checked out file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions=CmisUpdateConflictException.class)
public void siteManagerShouldNotMoveCheckedOutFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.and().checkOut().assertThat().documentIsCheckedOut()
.then().usingResource(sourceFile)
.moveTo(targetFolder).and().assertThat().existsInRepo()
.and().assertThat().documentIsCheckedOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to move folder with checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void siteManagerShouldMoveFolderWithCheckedOutFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
sourceFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFolder(sourceFolder).and().assertThat().existsInRepo()
.then().usingResource(sourceFolder)
.createFile(sourceFile, VersioningState.CHECKEDOUT)
.and().assertThat().existsInRepo()
.assertThat().documentIsCheckedOut()
.then().usingResource(sourceFolder)
.moveTo(targetFolder).and().assertThat().existsInRepo()
.and().assertThat().hasFiles(sourceFile);
FileModel checkedOutDoc = cmisApi.getFiles().get(0);
cmisApi.usingResource(checkedOutDoc).assertThat().documentIsCheckedOut();
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify unauthorized user is no able to move a file")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserCannotMovesFile() throws Exception
{
targetFolder = FolderModel.getRandomFolderModel();
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(targetFolder).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(unauthorizedUser)
.then().moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Manager verify PWC document object cannot be moved")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = CmisUpdateConflictException.class)
public void managerCannotMovePWCDocumentObject() throws Exception
{
sourceFile = dataContent.usingUser(siteManager).usingSite(publicSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
FileModel pwcFile = cmisApi.authenticateUser(siteManager).usingResource(sourceFile).checkOut().withCMISUtil().getPWCFileModel();
cmisApi.usingResource(pwcFile).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can move Document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void contributorCanMoveDocumentCreatedBySelf() throws Exception
{
sourceFile = dataContent.usingUser(contributorUser).usingSite(publicSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(contributorUser).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(contributorUser).usingResource(sourceFile).moveTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFile)
.usingSite(publicSite).assertThat().doesNotHaveFile(sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor cannot move Document created by Manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void contributorCannotMoveDocumentCreatedByManager() throws Exception
{
sourceFile = dataContent.usingUser(siteManager).usingSite(publicSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(contributorUser).usingResource(sourceFile).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can move Folder created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void contributorCanMoveFolderCreatedBySelf() throws Exception
{
sourceFolder = dataContent.usingUser(contributorUser).usingSite(publicSite).createFolder();
targetFolder = dataContent.usingUser(contributorUser).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(contributorUser).usingResource(sourceFolder).moveTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFolder)
.usingSite(publicSite).assertThat().doesNotHaveFolder(sourceFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor cannot move Folder created by Manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void contributorCannotMoveFolderCreatedByManager() throws Exception
{
sourceFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(contributorUser).usingResource(sourceFolder).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can move Document created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void collaboratorCanMoveDocumentCreatedBySelf() throws Exception
{
sourceFile = dataContent.usingUser(collaboratorUser).usingSite(publicSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(collaboratorUser).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(collaboratorUser).usingResource(sourceFile).moveTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFile)
.usingSite(publicSite).assertThat().doesNotHaveFile(sourceFile);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator cannot move Document created by Manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void collaboratorCannotMoveDocumentCreatedByManager() throws Exception
{
sourceFile = dataContent.usingUser(siteManager).usingSite(publicSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(collaboratorUser).usingResource(sourceFile).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can move Folder created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void collaboratorCanMoveFolderCreatedBySelf() throws Exception
{
sourceFolder = dataContent.usingUser(collaboratorUser).usingSite(publicSite).createFolder();
targetFolder = dataContent.usingUser(collaboratorUser).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(collaboratorUser).usingResource(sourceFolder).moveTo(targetFolder)
.usingResource(targetFolder).assertThat().hasChildren(sourceFolder)
.usingSite(publicSite).assertThat().doesNotHaveFolder(sourceFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator cannot move Folder created by Manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void collaboratorCannotMoveFolderCreatedByManager() throws Exception
{
sourceFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(collaboratorUser).usingResource(sourceFolder).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify consumer cannot move Document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerCannotMoveDocument() throws Exception
{
sourceFile = dataContent.usingUser(siteManager).usingSite(publicSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(consumerUser).usingResource(sourceFile).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify consumer cannot move Folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void consumerCannotMoveFolder() throws Exception
{
sourceFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
targetFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
cmisApi.authenticateUser(consumerUser).usingResource(sourceFolder).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot move Document from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotMoveDocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
sourceFile = dataContent.usingUser(siteManager).usingSite(privateSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(siteManager).usingSite(privateSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFile).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot move Folder from private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotMoveFolderFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
sourceFolder = dataContent.usingUser(siteManager).usingSite(privateSite).createFolder();
targetFolder = dataContent.usingUser(siteManager).usingSite(privateSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFolder).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot move Document from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotMoveDocumentFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite();
sourceFile = dataContent.usingUser(siteManager).usingSite(moderatedSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
targetFolder = dataContent.usingUser(siteManager).usingSite(moderatedSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFile).moveTo(targetFolder);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify unauthorized user cannot move Folder from moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisUnauthorizedException.class, CmisPermissionDeniedException.class})
public void unauthorizedUserCannotMoveFolderFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite();
sourceFolder = dataContent.usingUser(siteManager).usingSite(moderatedSite).createFolder();
targetFolder = dataContent.usingUser(siteManager).usingSite(moderatedSite).createFolder();
cmisApi.authenticateUser(unauthorizedUser).usingResource(sourceFolder).moveTo(targetFolder);
}
}

View File

@@ -0,0 +1,267 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/29/2016.
*/
public class RelationshipTests extends CmisTest
{
UserModel siteManager;
SiteModel publicSite, privateSite;
FileModel sourceFile, targetFile;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to create relationship between a source object and a target object in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCreatesRelationshipBetween2Files() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create relationship between a invalid sources with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotCreateRelWithInvalidSources() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().delete().assertThat().doesNotExistInRepo()
.createFile(sourceFile).and().delete().assertThat().doesNotExistInRepo()
.then().createRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create relationship with checkout source document with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanCreateRelWithCheckedOutSourceDocument() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.then().createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that inexistent user is not able to create relationship between documents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void inexistentUserCannotCreateRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(UserModel.getRandomUserModel())
.createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@Bug(id="REPO-4301")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that user that was deleted is not able to create relationship between documents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void deletedUserCannotCreateRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
UserModel toBeDeleted = dataUser.createRandomTestUser();
FolderModel shared = FolderModel.getSharedFolderModel();
cmisApi.authenticateUser(toBeDeleted)
.usingResource(shared)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo();
dataUser.deleteUser(toBeDeleted);
cmisApi.createRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify that site manager is able to create relationship between documents with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanCreateRelationshipInPrivateSite() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(dataUser.getAdminUser())
.usingSite(privateSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(siteManager)
.createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create relationship between a invalid sources with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotGetRelWithInvalidObject() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FileModel invalidFile = FileModel.getRandomFileModel(FileType.HTML);
invalidFile.setCmisLocation("/" + invalidFile.getName() + "/");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile)
.createFile(sourceFile)
.then().createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile)
.assertThat().objectHasRelationshipWith(invalidFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin is able to create relationship between a source folder and a target file with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminCreatesRelBetweenSourceFolderAndTargetFile() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel sourceFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(dataUser.getAdminUser()).usingSite(publicSite)
.createFile(targetFile).assertThat().existsInRepo()
.createFolder(sourceFolder).assertThat().existsInRepo()
.then().createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify contributor is not able to create relationship between a source object and a target object in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS},expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void contributorCannotCreateRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(sourceFile).createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify collaborator is able to create relationship between a source object and a target object in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanCreateRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(sourceFile).createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify consumer is not able to create relationship between a source object and a target object in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS},expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotCreateRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(sourceFile).createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify unauthorized user is not able to create relationship between a source object and a target object from a private site with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserCannotCreateRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(privateSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.usingResource(sourceFile).createRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify unauthorized user is not able to get relationship between a source object and a target object from a private site with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserCannotGetRelationship() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(privateSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo()
.usingResource(sourceFile).createRelationshipWith(targetFile)
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.and().assertThat().objectHasRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to create relationship for PWC source document with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisInvalidArgumentException.class,
expectedExceptionsMessageRegExp = "^Source is not the latest version of a document, a folder or an item object!$")
public void siteManagerCannotCreateRelationshipPWCSourceFile() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.createFile(sourceFile).and().assertThat().existsInRepo().then().checkOut()
.assertThat().documentIsCheckedOut()
.usingPWCDocument().createRelationshipWith(targetFile);
}
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to create relationship with checkout target document with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanCreateRelWithCheckedOutTargetDocument() throws Exception
{
sourceFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
targetFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(targetFile).and().assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.createFile(sourceFile).and().assertThat().existsInRepo()
.then().createRelationshipWith(targetFile)
.and().assertThat().objectHasRelationshipWith(targetFile);
}
}

View File

@@ -0,0 +1,243 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 10/3/2016.
*/
public class RemoveObjectFromFolderTests extends CmisTest
{
UserModel unauthorizedUser;
UserModel siteManager;
UserModel contributorUser;
UserModel collaboratorUser;
UserModel consumerUser;
SiteModel publicSite;
FolderModel parentFolder, testFolder;
FileModel testFile;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
unauthorizedUser = dataUser.createRandomTestUser();
siteManager = dataUser.createRandomTestUser();
contributorUser = dataUser.createRandomTestUser();
collaboratorUser = dataUser.createRandomTestUser();
consumerUser = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
dataUser.addUserToSite(consumerUser, publicSite, UserRole.SiteConsumer);
dataUser.addUserToSite(collaboratorUser, publicSite, UserRole.SiteCollaborator);
dataUser.addUserToSite(contributorUser, publicSite, UserRole.SiteContributor);
parentFolder = FolderModel.getRandomFolderModel();
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFolder(testFolder).assertThat().existsInRepo()
.createFolder(parentFolder).assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to remove a document from folder in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerShouldRemoveFileToFolder() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingResource(parentFolder)
.createFile(testFile).assertThat().existsInRepo()
.and().addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo()
.when().removeDocumentFromFolder(testFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to leave a document without parent folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisInvalidArgumentException.class, expectedExceptionsMessageRegExp = "^Object is not a document!$")
public void siteManagerShouldNotRemoveFolderFromFolder() throws Exception
{
FolderModel subFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager).usingResource(parentFolder)
.createFolder(subFolder).assertThat().existsInRepo()
.when().removeDocumentFromFolder(testFolder).assertThat().doesNotExistInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to remove a document without parent folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerShouldNotRemoveInvalidFileFromFolder() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
testFile.setCmisLocation("/" + testFile.getName() + "/");
cmisApi.authenticateUser(siteManager).usingResource(testFile)
.when().removeDocumentFromFolder(testFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to remove valid document from invalid folder with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerShouldNotRemoveFileToInvalidFolder() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
FolderModel invalidFolder = FolderModel.getRandomFolderModel();
invalidFolder.setCmisLocation("/" + invalidFolder.getName() + "/");
cmisApi.authenticateUser(siteManager).usingResource(parentFolder)
.createFile(testFile).assertThat().existsInRepo()
.and().addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo()
.when().removeDocumentFromFolder(invalidFolder)
.assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to remove a checked out document from folder in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerShouldRemovePWCFileToFolder() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingResource(parentFolder)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.usingPWCDocument().addDocumentToFolder(testFolder, true)
.then().assertThat().existsInRepo()
.and().assertThat().documentIsCheckedOut()
.when().removeDocumentFromFolder(testFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo()
.and().assertThat().documentIsCheckedOut();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify unauthorized user is not able to remove a document from folder")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserShouldNotRemoveFileToFolder() throws Exception
{
UserModel unauthorizedUser = dataUser.createRandomTestUser();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager)
.usingResource(parentFolder)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(unauthorizedUser)
.removeDocumentFromFolder(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can remove document from folder created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void contributorCanRemoveDocumentFromFolderCreatedBySelf() throws Exception
{
parentFolder = dataContent.usingUser(contributorUser).usingSite(publicSite).createFolder();
testFolder = dataContent.usingUser(contributorUser).usingSite(publicSite).createFolder();
testFile = dataContent.usingUser(contributorUser).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(contributorUser).usingResource(testFile)
.addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo()
.removeDocumentFromFolder(testFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify contributor can remove document from folder created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void contributorCannotRemoveDocumentFromFolderCreatedByManager() throws Exception
{
parentFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
testFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
testFile = dataContent.usingUser(siteManager).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(siteManager).usingResource(testFile)
.addDocumentToFolder(testFolder, true);
cmisApi.authenticateUser(contributorUser).usingResource(testFile).removeDocumentFromFolder(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can remove document from folder created by self")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS })
public void collaboratorCanRemoveDocumentFromFolderCreatedBySelf() throws Exception
{
parentFolder = dataContent.usingUser(collaboratorUser).usingSite(publicSite).createFolder();
testFolder = dataContent.usingUser(collaboratorUser).usingSite(publicSite).createFolder();
testFile = dataContent.usingUser(collaboratorUser).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(collaboratorUser).usingResource(testFile)
.addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo()
.removeDocumentFromFolder(testFolder).assertThat().doesNotExistInRepo()
.usingResource(testFile).assertThat().existsInRepo();
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify collaborator can remove document from folder created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void collaboratorCannotRemoveDocumentFromFolderCreatedByManager() throws Exception
{
parentFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
testFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
testFile = dataContent.usingUser(siteManager).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(siteManager).usingResource(testFile)
.addDocumentToFolder(testFolder, true);
cmisApi.authenticateUser(collaboratorUser).usingResource(testFile).removeDocumentFromFolder(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify consumer cannot remove document from folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotRemoveDocumentFromFolder() throws Exception
{
parentFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
testFolder = dataContent.usingUser(siteManager).usingSite(publicSite).createFolder();
testFile = dataContent.usingUser(siteManager).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(siteManager).usingResource(testFile)
.addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo();
cmisApi.authenticateUser(consumerUser).usingResource(testFile).removeDocumentFromFolder(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify remove document from folder by user that is outside a private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserCannotRemoveDocumentFromPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
parentFolder = dataContent.usingUser(siteManager).usingSite(privateSite).createFolder();
testFolder = dataContent.usingUser(siteManager).usingSite(privateSite).createFolder();
testFile = dataContent.usingUser(siteManager).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(siteManager).usingResource(testFile)
.addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo();
cmisApi.authenticateUser(unauthorizedUser).usingResource(testFile).removeDocumentFromFolder(testFolder);
}
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify remove document from folder by user that is outside a moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS }, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void unauthorizedUserCannotRemoveDocumentFromModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(siteManager).createModeratedRandomSite();
parentFolder = dataContent.usingUser(siteManager).usingSite(moderatedSite).createFolder();
testFolder = dataContent.usingUser(siteManager).usingSite(moderatedSite).createFolder();
testFile = dataContent.usingUser(siteManager).usingResource(parentFolder)
.createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
cmisApi.authenticateUser(siteManager).usingResource(testFile)
.addDocumentToFolder(testFolder, true).then().assertThat().existsInRepo();
cmisApi.authenticateUser(unauthorizedUser).usingResource(testFile).removeDocumentFromFolder(testFolder);
}
}

View File

@@ -0,0 +1,351 @@
package org.alfresco.cmis;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class RenameTests extends CmisTest
{
SiteModel testSite;
UserModel managerUser, inexistentUser, nonInvitedUser;
FileModel testFile;
FolderModel testFolder;
private DataUser.ListUserWithRoles usersWithRoles;
private String prefix = "-edit";
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerUser = dataUser.createRandomTestUser();
nonInvitedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(managerUser).createPublicRandomSite();
inexistentUser = new UserModel("inexistent", "inexistent");
usersWithRoles = dataUser.usingUser(managerUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to rename document and folder created by himself")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerCanRenameContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.createFolder(testFolder).assertThat().existsInRepo()
.then().usingResource(testFile)
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo()
.then().usingResource(testFolder)
.rename(testFolder.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFolder).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify admin user is able to rename document and folder created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void adminCanRenameContentFromPublicSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.createFolder(testFolder).assertThat().existsInRepo()
.then().authenticateUser(dataUser.getAdminUser())
.usingResource(testFile)
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo()
.usingResource(testFolder)
.rename(testFolder.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFolder).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename inexistent document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotRenameInexistentDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
testFile.setCmisLocation("/fake-folder/test.txt");
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.then().usingResource(testFile)
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename inexistent folder")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerCannotRenameInexistentFolder() throws Exception
{
FolderModel folder = FolderModel.getRandomFolderModel();
folder.setCmisLocation("/" + folder.getName() + "/");
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.then().usingResource(folder)
.rename(prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename document with invalid symbols")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotRenameDocumentInvalidSymbols() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().usingResource(testFile)
.rename("/.:?|\\`\\.txt").assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename folder with invalid symbols")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotRenameFolderInvalidSymbols() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().usingResource(testFolder)
.rename("/.:?|\\`\\.txt").assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename document with empty string")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="New name must not be empty!*")
public void siteManagerCannotRenameDocumentEmptyName() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().usingResource(testFile)
.rename("").assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename folder with empty name")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="New name must not be empty!*")
public void siteManagerCannotRenameFolderEmptyName() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().usingResource(testFolder)
.rename("").assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename checked out document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUpdateConflictException.class)
public void siteManagerCannotRenameCheckedOutDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.then().usingResource(testFile)
.rename(testFile.getName() + prefix).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to rename pwc document")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRenamePwcDocument() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
FileModel renamedPwc = new FileModel("pwc" + prefix + " (Working Copy)");
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().assertThat().documentIsCheckedOut()
.then().usingResource(testFile)
.usingPWCDocument().assertThat().existsInRepo()
.rename("pwc" + prefix);
renamedPwc.setCmisLocation(testFile.getCmisLocation().replace(testFile.getName(), renamedPwc.getName()));
cmisApi.usingResource(renamedPwc).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to rename document with same name")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRenameDocumentWithSameName() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().usingResource(testFile)
.rename(testFile.getName()).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to rename document with multiple versions")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRenameDocumentWithMultipleVersions() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().update("first content").assertThat().documentHasVersion(1.1)
.then().update("second content").assertThat().documentHasVersion(1.2)
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.and().assertThat().documentHasVersion(1.2);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to rename document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteCollaboratorCanRenameDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to rename folder created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteCollaboratorCanRenameFolderCreatedByManager() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.rename(testFolder.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFolder).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to rename folder created by collaborator")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanRenameFolderCreatedByCollaborator() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().authenticateUser(managerUser)
.rename(testFolder.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFolder).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to rename document created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteCollaboratorCanRenameDocumentCreatedByHimself() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is not able to rename document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void siteContributorCannotRenameDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to rename document created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteContributorCanRenameDocumentCreatedByHimself() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.rename(testFile.getName() + prefix).assertThat().existsInRepo()
.when().usingResource(testFile).assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer is not able to rename document created by manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void siteConsumerCannotRenameDocumentCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.rename(testFile.getName() + prefix).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is not able to rename document in public site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void siteConsumerCannotRenameDocumentInPublicSite() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.rename(testFile.getName() + prefix).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is not able to rename document in private site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotRenameDocumentInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(managerUser).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(privateSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(nonInvitedUser)
.rename(testFile.getName() + prefix).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is not able to rename document in moderated site")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotRenameDocumentInModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(managerUser).createModeratedRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(moderatedSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(nonInvitedUser)
.rename(testFile.getName() + prefix).assertThat().existsInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to rename document with same name as another file in same location")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisContentAlreadyExistsException.class,
expectedExceptionsMessageRegExp="An object with this name already exists.*")
public void siteManagerCannotRenameDocumentWithSameNameFromOtherFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
FileModel secondFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(managerUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.createFile(secondFile)
.then().usingResource(testFile)
.rename(secondFile.getName()).assertThat().existsInRepo();
}
}

View File

@@ -0,0 +1,177 @@
package org.alfresco.cmis;
import org.alfresco.utility.Utility;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
public class RenditionTests extends CmisTest
{
private SiteModel testSite;
private UserModel testUser, inexistentUser, nonInvitedUser;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
nonInvitedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
inexistentUser = new UserModel("inexistent", "inexistent");
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin can get renditions for valid Document object")
public void adminShouldGetRenditionsForDocument() throws Exception
{
FileModel txtModel = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(dataUser.getAdminUser()).usingShared().createFile(txtModel);
Utility.sleep(300, 10000, () -> cmisApi.usingResource(txtModel).assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS}, expectedExceptions = {CmisObjectNotFoundException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify admin can get renditions for invalid Document object")
public void adminCannotGetRenditionsForInvalidDocument() throws Exception
{
FileModel invalidFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
invalidFile.setCmisLocation("/" + invalidFile.getName() + "/");
cmisApi.authenticateUser(dataUser.getAdminUser()).usingShared()
.then().usingResource(invalidFile).assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable();
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager can get renditions for valid Document")
public void managerGetRenditionsForDocument() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile);
Utility.sleep(300, 10000, () -> cmisApi.authenticateUser(testUser)
.usingResource(testFile).assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator can get renditions for valid Document")
public void collaboratorGetRenditionsForDocument() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile);
Utility.sleep(300, 10000, () -> cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFile).assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor can get renditions for valid Document")
public void contributorGetRenditionsForDocument() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile);
Utility.sleep(300, 10000, () -> cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(testFile).assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer can get renditions for valid Document")
public void consumerGetRenditionsForDocument() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile);
Utility.sleep(300, 10000, () -> cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(testFile).assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager can get renditions for checked out document")
public void managerGetRenditionsForCheckedOutDocument() throws Exception
{
FileModel checkedDoc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(checkedDoc, VersioningState.CHECKEDOUT).assertThat().documentIsCheckedOut();
Utility.sleep(300, 10000, () -> cmisApi.usingResource(checkedDoc)
.assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user can get renditions in public site")
public void nonInvitedUserGetRenditionsInPublicSite() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile);
Utility.sleep(300, 10000, () -> cmisApi.authenticateUser(nonInvitedUser)
.usingResource(testFile)
.assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable());
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user cannot get renditions in private site")
public void nonInvitedUserCannotGetRenditionsInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
FileModel privateDoc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(privateDoc).assertThat().existsInRepo()
.authenticateUser(nonInvitedUser)
.usingResource(privateDoc)
.assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user cannot get renditions in moderated site")
public void nonInvitedUserCannotGetRenditionsInModeratedSite() throws Exception
{
SiteModel moderatedSite = dataSite.usingUser(testUser).createPrivateRandomSite();
FileModel moderatedDoc = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(moderatedSite)
.createFile(moderatedDoc).assertThat().existsInRepo()
.authenticateUser(nonInvitedUser)
.usingResource(moderatedDoc)
.assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS}, expectedExceptions=CmisUnauthorizedException.class)
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify inexistent user cannot get renditions")
public void inexistentUserCannotGetRenditions() throws Exception
{
FileModel testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile);
cmisApi.authenticateUser(inexistentUser)
.usingResource(testFile)
.assertThat().renditionIsAvailable()
.assertThat().thumbnailRenditionIsAvailable();
}
}

View File

@@ -0,0 +1,119 @@
package org.alfresco.cmis;
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.chemistry.opencmis.commons.data.AclCapabilities;
import org.apache.chemistry.opencmis.commons.data.RepositoryCapabilities;
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
import org.apache.chemistry.opencmis.commons.enums.BindingType;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class RepositoryInfoTests extends CmisTest
{
UserModel testUser;
UserModel unauthorizedUser;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
unauthorizedUser = dataUser.createRandomTestUser();
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY, description = "Verify that valid user can get repositories")
public void validUserCanGetRepositories() throws Exception
{
Assert.assertNotNull(cmisApi.authenticateUser(testUser).getSession());
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS}, expectedExceptions = CmisUnauthorizedException.class)
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY, description = "Verify that valid user with invalid password cannot get repositories")
public void unauthorizedUserCannotGetRepositories() throws Exception
{
unauthorizedUser.setPassword("invalidPass");
cmisApi.authenticateUser(unauthorizedUser);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY, description = "Verify that valid user can get the repository informations")
public void validUserCanGetRepositoryInfo() throws Exception
{
RepositoryInfo repoInfo = cmisApi.authenticateUser(testUser).getRepositoryInfo();
Assert.assertNotNull(repoInfo.getRootFolderId());
Assert.assertNotNull(repoInfo.getProductVersion());
Assert.assertNotNull(repoInfo.getRootFolderId());
Assert.assertNotNull(repoInfo.getId());
Assert.assertEquals(repoInfo.getProductName(), String.format("Alfresco %s", serverHealth.getAlfrescoEdition()));
Assert.assertEquals(repoInfo.getVendorName(), "Alfresco");
RepositoryCapabilities capabilities = repoInfo.getCapabilities();
Assert.assertNotNull(capabilities);
Assert.assertEquals(capabilities.getContentStreamUpdatesCapability().value(), "anytime", "Verify repository capability: capabilityContentStreamUpdatability");
Assert.assertEquals(capabilities.getRenditionsCapability().value(), "read", "Verify repository capability: capabilityRenditions");
Assert.assertTrue(capabilities.isGetDescendantsSupported(), "Verify repository capability: capabilityGetDescendants");
Assert.assertTrue(capabilities.isGetFolderTreeSupported(), "Verify repository capability: capabilityGetFolderTree");
Assert.assertTrue(capabilities.isMultifilingSupported(), "Verify repository capability: capabilityMultifiling");
Assert.assertFalse(capabilities.isUnfilingSupported(), "Verify repository capability: capabilityUnfiling");
Assert.assertFalse(capabilities.isVersionSpecificFilingSupported(), "Verify repository capability: capabilityVersionSpecificFiling");
Assert.assertFalse(capabilities.isPwcSearchableSupported(), "Verify repository capability: capabilityPWCSearchable");
Assert.assertTrue(capabilities.isPwcUpdatableSupported(), "Verify repository capability: capabilityPWCUpdatable");
Assert.assertFalse(capabilities.isAllVersionsSearchableSupported(), "Verify repository capability: capabilityAllVersionsSearchable");
Assert.assertEquals(capabilities.getQueryCapability().value(), "bothcombined", "Verify repository capability: capabilityQuery");
Assert.assertEquals(capabilities.getJoinCapability().value(), "none", "Verify repository capability: capabilityJoin");
Assert.assertEquals(capabilities.getAclCapability().value(), "manage", "Verify repository capability: capabilityACL");
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.SANITY, description = "Verify that valid user can get Acl Capabilities")
public void validUserCanGetAclCapabilities() throws Exception
{
AclCapabilities aclCapabilities = cmisApi.authenticateUser(testUser).getAclCapabilities();
Assert.assertNotNull(aclCapabilities);
Assert.assertFalse(aclCapabilities.getPermissions().isEmpty(), "Verify acl capabilities: getPermissions");
Assert.assertEquals(aclCapabilities.getSupportedPermissions().value(), "both", "Verify acl capabilities: getSupportedPermissions");
Assert.assertEquals(aclCapabilities.getAclPropagation().value(), "propagate", "Verify acl capabilities: getAclPropagation");
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUnauthorizedException.class)
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION, description = "Verify that invalid user cannot get repositories")
public void invalidUserCannotGetRepositories() throws Exception
{
UserModel invalidUser = UserModel.getRandomUserModel();
cmisApi.authenticateUser(invalidUser).getRepositoryInfo();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisConnectionException.class})
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION, description = "Verify that invalid user cannot get repositories")
public void userCannotGetRepositoriesUsingWrongBrowserUrl() throws Exception
{
String wrongUrlPath = "//alfresco//api//-default-//public//cmis//versions//1.1";
cmisApi.authUserUsingBrowserUrlAndBindingType(testUser, wrongUrlPath, BindingType.BROWSER.value()).getRepositoryInfo();
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {IllegalArgumentException.class, CmisRuntimeException.class}, expectedExceptionsMessageRegExp = "Invalid binding type!")
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION, description = "Verify that invalid user cannot get repositories")
public void userCannotGetRepositoriesUsingWrongBindingType() throws Exception
{
String wrongBindingType = BindingType.BROWSER.value() + "w";
cmisApi.authUserUsingBrowserUrlAndBindingType(testUser, cmisApi.cmisProperties.envProperty().getFullServerUrl() + cmisApi.cmisProperties.getBasePath(), wrongBindingType).getRepositoryInfo();
}
@Bug(id="REPO-4301")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUnauthorizedException.class)
@TestRail(section = { "cmis-api" }, executionType = ExecutionType.REGRESSION, description = "Verify that disabled user cannot get repositories")
public void disabledUserCannotGetRepositories() throws Exception
{
UserModel disabledUser = dataUser.createRandomTestUser();
Assert.assertNotNull(cmisApi.authenticateUser(disabledUser).getRepositoryInfo());
dataUser.usingAdmin().disableUser(disabledUser);
cmisApi.authenticateUser(disabledUser).getRepositoryInfo();
}
}

View File

@@ -0,0 +1,287 @@
package org.alfresco.cmis;
import java.util.Date;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
import org.alfresco.utility.model.FileModel;
import org.alfresco.utility.model.FileType;
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.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.commons.lang.time.DateUtils;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class SecondaryTypesTests extends CmisTest
{
SiteModel testSite;
UserModel testUser, nonInvitedUser;
private DataUser.ListUserWithRoles usersWithRoles;
FileModel managerFile;
FolderModel managerFolder;
String titledAspect = "P:cm:titled";
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
managerFile = FileModel.getRandomFileModel(FileType.MSWORD2007, documentContent);
managerFolder = FolderModel.getRandomFolderModel();
testUser = dataUser.createRandomTestUser();
nonInvitedUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(managerFile)
.createFolder(managerFolder);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get secondary types for Document")
public void userCanGetSecondaryTypesForDocument() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to get secondary types for Folder")
public void userCanGetSecondaryTypesForFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFolder)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = {CmisObjectNotFoundException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to get secondary types for Folder")
public void userCannotGetSecondaryTypesForInvalidObject() throws Exception
{
FolderModel folder = FolderModel.getRandomFolderModel();
folder.setCmisLocation("/" + folder.getName() + "/");
cmisApi.authenticateUser(testUser)
.usingResource(folder)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is NOT able to get invalid secondary type for Folder")
public void invalidSecondaryTypeIsNotAvailableForFolder() throws Exception
{
FolderModel folder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(folder).and().assertThat().existsInRepo()
.and().assertThat().secondaryTypeIsNotAvailable(titledAspect + "-fake");
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to get secondary types")
public void collaboratorCanGetSecondaryTypesForContent() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(managerFolder)
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().usingResource(managerFile)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to get secondary types")
public void contributorCanGetSecondaryTypesForContent() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.usingResource(managerFolder)
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().usingResource(managerFile)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site consumer is able to get secondary types")
public void consumerCanGetSecondaryTypesForContent() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.usingResource(managerFolder)
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().usingResource(managerFile)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is able to get secondary types in public site")
public void nonInvitedUserCanGetSecondaryTypesForContentInPublicSite() throws Exception
{
cmisApi.authenticateUser(nonInvitedUser)
.usingResource(managerFolder)
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().usingResource(managerFile)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get secondary types in private site")
public void nonInvitedUserCannotGetSecondaryTypesForContentInPrivateSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createPrivateRandomSite();
FileModel privateDoc = FileModel.getRandomFileModel(FileType.MSPOWERPOINT2007);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(privateDoc)
.authenticateUser(nonInvitedUser)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify non invited user is not able to get secondary types in moderated site")
public void nonInvitedUserCannotGetSecondaryTypesInModeratedSite() throws Exception
{
SiteModel privateSite = dataSite.usingUser(testUser).createModeratedRandomSite();
FileModel privateDoc = FileModel.getRandomFileModel(FileType.MSPOWERPOINT2007);
cmisApi.authenticateUser(testUser).usingSite(privateSite)
.createFile(privateDoc)
.authenticateUser(nonInvitedUser)
.assertThat().secondaryTypeIsAvailable(titledAspect);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to add secondary types for Document")
public void managerCanAddSecondaryTypesForDocument() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.addSecondaryTypes("P:cm:dublincore")
.assertThat().secondaryTypeIsAvailable("P:cm:dublincore")
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().updateProperty("cm:subject", "TAS Subject")
.updateProperty("cm:rights", "TAS Rights")
.updateProperty("cm:publisher", "TAS Team")
.then().assertThat().objectHasProperty("cm:subject", "TAS Subject")
.assertThat().objectHasProperty("cm:rights", "TAS Rights")
.assertThat().objectHasProperty("cm:publisher", "TAS Team");
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
description = "Verify site manager is able to add secondary types for folder")
public void managerCanAddSecondaryTypesForFolder() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFolder)
.addSecondaryTypes("P:cm:geographic")
.assertThat().secondaryTypeIsAvailable("P:cm:geographic")
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().updateProperty("cm:longitude", 455.21)
.updateProperty("cm:latitude", 101.32)
.then().assertThat().objectHasProperty("cm:longitude", 455.21)
.assertThat().objectHasProperty("cm:latitude", 101.32);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class,
expectedExceptionsMessageRegExp="Type 'P:cm:fakeAspect' is unknown!*")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to add fake secondary type")
public void managerCannotAddInexistentSecondaryType() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFolder)
.addSecondaryTypes("P:cm:fakeAspect");
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to add twice same secondary type")
public void managerCanAddTwiceSameSecondaryType() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.addSecondaryTypes("P:cm:dublincore")
.assertThat().secondaryTypeIsAvailable("P:cm:dublincore")
.then().addSecondaryTypes("P:cm:dublincore")
.assertThat().secondaryTypeIsAvailable("P:cm:dublincore");
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site collaborator is able to add secondary types for document created by manager")
public void collaboratorCanAddAspectForDocument() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingResource(managerFile)
.addSecondaryTypes("P:audio:audio")
.assertThat().secondaryTypeIsAvailable("P:audio:audio")
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().updateProperty("audio:channelType", "TAS")
.updateProperty("audio:trackNumber", 9)
.updateProperty("audio:sampleType", "TAS Sample")
.then().assertThat().objectHasProperty("audio:channelType", "TAS")
.assertThat().objectHasProperty("audio:trackNumber", 9)
.assertThat().objectHasProperty("audio:sampleType", "TAS Sample");
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to add secondary types for document created by manager")
public void contributorCanAddAspectForDocument() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingResource(managerFile)
.addSecondaryTypes("P:dp:restrictable")
.assertThat().secondaryTypeIsAvailable("P:dp:restrictable")
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().updateProperty("dp:offlineExpiresAfter", 2)
.and().assertThat().objectHasProperty("dp:offlineExpiresAfter", 2);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site contributor is able to add secondary types for document created by manager")
public void consumerCanAddAspectForDocument() throws Exception
{
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)).usingResource(managerFile)
.addSecondaryTypes("P:dp:restrictable")
.assertThat().secondaryTypeIsAvailable("P:dp:restrictable")
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().updateProperty("dp:offlineExpiresAfter", 2)
.and().assertThat().objectHasProperty("dp:offlineExpiresAfter", 2);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is able to add twice same secondary type")
public void managerCanAddDateProperty() throws Exception
{
Date today = new Date();
Date tomorow = new Date();
tomorow = DateUtils.addDays(tomorow, 1);
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.addSecondaryTypes("P:cm:effectivity")
.assertThat().secondaryTypeIsAvailable("P:cm:effectivity")
.then().updateProperty("cm:to", today)
.updateProperty("cm:from", tomorow)
.and().assertThat().objectHasProperty("cm:to", today)
.assertThat().objectHasProperty("cm:from", tomorow);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class,
expectedExceptionsMessageRegExp="Property 'cm:fake-prop' is not valid for this type or one of the secondary types!*")
@TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
description = "Verify site manager is not able to update aspect with fake property")
public void managerCannotUpdateFakePropertyFromAspect() throws Exception
{
cmisApi.authenticateUser(testUser).usingResource(managerFile)
.addSecondaryTypes("P:cm:dublincore")
.assertThat().secondaryTypeIsAvailable("P:cm:dublincore")
.assertThat().secondaryTypeIsAvailable(titledAspect)
.then().updateProperty("cm:fake-prop", "fake-prop");
}
}

View File

@@ -0,0 +1,246 @@
package org.alfresco.cmis;
import org.alfresco.cmis.exception.InvalidCmisObjectException;
import org.alfresco.utility.constants.UserRole;
import org.alfresco.utility.data.DataUser;
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.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/28/2016.
*/
public class SetContentTests extends CmisTest
{
UserModel siteManager;
SiteModel publicSite;
FileModel testFile;
FolderModel testFolder;
private String someContent = "some content";
private String secondContent = "second content";
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
siteManager = dataUser.createRandomTestUser();
publicSite = dataSite.usingUser(siteManager).createPublicRandomSite();
usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteManager, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to set content to a valid document in DocumentLibrary with CMIS")
public void siteManagerSetFileContentForFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().update("content")
.then().setContent(someContent).and().refreshResource()
.then().assertThat().contentIs(someContent)
.and().assertThat().contentLengthIs(12);
}
@Test(expectedExceptions = InvalidCmisObjectException.class, groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify if exception is thrown when user tries to set content to an invalid document in DocumentLibrary with CMIS")
public void siteManagerSetFolderContent() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(siteManager)
.usingSite(publicSite)
.createFolder(testFolder).setContent(someContent);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify that inexistent user is not able to set content to a document with CMIS")
public void inexistentUserCannotSetFileContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentLengthIs(0)
.then().authenticateUser(UserModel.getRandomUserModel())
.setContent(someContent);
}
@Bug(id="ACE-5614")
@Test(groups = { TestGroup.REGRESSION , TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to set content to a document with no content with overwrite parameter set to false with CMIS")
public void siteManagerCanSetContentWithFalseOverwriteToDocWithNoContent() throws Exception
{
FileModel newFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(newFile).assertThat().existsInRepo()
.and().assertThat().contentLengthIs(0)
.then().setContent(someContent, false).and()
.and().assertThat().contentIs(someContent);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisContentAlreadyExistsException.class)
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to set content to a document with content with overwrite parameter set to false with CMIS")
public void siteManagerCanSetContentWithFalseOverwriteToDocWithContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, someContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.and().assertThat().contentIs(someContent)
.then().setContent(secondContent, false);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to set content to a document")
public void unauthorizedUserCannotSetContent() throws Exception
{
UserModel unauthorizedUser = dataUser.createRandomTestUser();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, someContent);
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(unauthorizedUser)
.setContent(secondContent);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify admin is able to set file content with CMIS")
public void adminCanSetFileContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(dataUser.getAdminUser())
.and().setContent(someContent).and().refreshResource()
.then().assertThat().contentIs(someContent)
.and().assertThat().contentLengthIs(12);
}
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to set file content for a file created by other user with CMIS")
public void managerCanSetFileContentForFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
.and().setContent(someContent).and().refreshResource()
.then().assertThat().contentIs(someContent)
.and().assertThat().contentLengthIs(12);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is not able to set content to a document created by other user with CMIS")
public void contributorCannotSetFileContentForFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
.then().setContent(someContent);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to set content to a document created by self with CMIS")
public void contributorCanSetFileContentForFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().setContent(someContent).and().refreshResource()
.then().assertThat().contentIs(someContent)
.and().assertThat().contentLengthIs(12);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to set content to a document created by other user with CMIS")
public void collaboratorCanSetFileContentForFileCreatedByOtherUser() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.then().usingResource(testFile)
.setContent(someContent).and().refreshResource()
.and().assertThat().contentIs(someContent)
.assertThat().contentLengthIs(12);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to set content to a document created by self with CMIS")
public void collaboratorCanSetFileContentForFileCreatedBySelf() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().setContent(someContent).and().refreshResource()
.then().assertThat().contentIs(someContent)
.and().assertThat().contentLengthIs(12);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer is not able to set file content with CMIS")
public void consumerCannotSetFileContent() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.then().setContent(someContent);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions = CmisUpdateConflictException.class, expectedExceptionsMessageRegExp = "^.*Cannot perform operation since the node.*is locked.$")
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to set content to a checked out document with CMIS")
public void siteManagerCannotSetContentToCheckedOutFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.setContent(someContent);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to set content to PWC document version with CMIS")
public void siteManagerSetContentToPWCFile() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "first content");
cmisApi.authenticateUser(siteManager).usingSite(publicSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.usingPWCDocument().setContent(someContent).and().refreshResource()
.then().assertThat().contentIs(someContent)
.and().assertThat().contentLengthIs(12);
}
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
@TestRail(section = {"cmis-api" }, executionType = ExecutionType.REGRESSION,
description = "Verify unauthorized user is not able to set content to a document from a private site")
public void unauthorizedUserCannotSetContentToPrivateSiteDoc() throws Exception
{
SiteModel privateSite = dataSite.usingUser(siteManager).createPrivateRandomSite();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, someContent);
cmisApi.authenticateUser(siteManager).usingSite(privateSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.usingResource(testFile).setContent(secondContent);
}
}

View File

@@ -0,0 +1,357 @@
package org.alfresco.cmis;
import java.util.HashMap;
import java.util.Map;
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.FileType;
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.report.Bug;
import org.alfresco.utility.testrail.ExecutionType;
import org.alfresco.utility.testrail.annotation.TestRail;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
/**
* Created by Claudia Agache on 9/30/2016.
*/
public class UpdatePropertiesTests extends CmisTest
{
UserModel testUser;
SiteModel testSite;
FileModel testFile;
FolderModel testFolder;
String propertyNameValue;
private DataUser.ListUserWithRoles usersWithRoles;
@BeforeClass(alwaysRun = true)
public void dataPreparation() throws Exception
{
testUser = dataUser.createRandomTestUser();
testSite = dataSite.usingUser(testUser).createPublicRandomSite();
dataContent.deployContentModel("shared-resources/model/tas-model.xml");
usersWithRoles = dataUser.usingUser(testUser)
.addUsersWithRolesToSite(testSite, UserRole.SiteContributor, UserRole.SiteCollaborator, UserRole.SiteConsumer);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to update properties to a valid document in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerUpdatesFileProperties() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().updateProperty("cmis:name", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:name", propertyNameValue)
.then().updateProperty("cmis:description", "some description")
.and().assertThat().contentPropertyHasValue("cmis:description", "some description");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.SANITY,
description = "Verify site manager is able to update properties to a valid folder in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.SANITY, TestGroup.CMIS})
public void siteManagerUpdatesFolderProperties() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder).assertThat().existsInRepo()
.then().updateProperty("cmis:name", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:name", propertyNameValue)
.then().updateProperty("cmis:description", "some description")
.and().assertThat().contentPropertyHasValue("cmis:description", "some description");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify if exception is thrown when user tries to update properties to a non existent document in DocumentLibrary with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisObjectNotFoundException.class)
public void siteManagerUpdatesNoneExistentFileProperties() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile).assertThat().existsInRepo()
.then().delete().and().assertThat().doesNotExistInRepo()
.then().updateProperty("cmis:name", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to update properties with invalid property with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=IllegalArgumentException.class)
public void siteManagerCannotUpdateFileWithInvalidProperty() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().updateProperty("cmis:fakeProp", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify that deleted user is not able to update properties with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void deletedUserCannotUpdateFileProperties() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
UserModel toBeDeleted = dataUser.createRandomTestUser();
FolderModel shared = FolderModel.getSharedFolderModel();
cmisApi.authenticateUser(toBeDeleted)
.usingResource(shared)
.createFile(testFile).and().assertThat().existsInRepo();
dataUser.deleteUser(toBeDeleted);
cmisApi.updateProperty("cmis:name", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to update name property while document is checked out with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCannotUpdatePWCDocumentName() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut()
.and().assertThat().documentIsCheckedOut()
.usingPWCDocument().updateProperty("cmis:name", testFile.getName() + "-edit")
.cancelCheckOut()
.then().usingResource(testFile)
.assertThat().contentPropertyHasValue("cmis:name", testFile.getName());
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to update the title and description while document is checked out with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanUpdateCheckOutDocTitleAndDescription() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().checkOut().and().assertThat().documentIsCheckedOut()
.then().usingPWCDocument()
.updateProperty("cmis:description", propertyNameValue)
.updateProperty("cm:title", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:description", propertyNameValue)
.assertThat().contentPropertyHasValue("cm:title", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to update the title and description for document with version is checked out with CMIS")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanUpdateDocumentWithVersion() throws Exception
{
propertyNameValue = RandomData.getRandomAlphanumeric();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite).createFile(testFile).assertThat().existsInRepo()
.then().update("first content").update("second content")
.updateProperty("cmis:description", propertyNameValue)
.updateProperty("cm:title", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:description", propertyNameValue)
.assertThat().contentPropertyHasValue("cm:title", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to update document name with invalid symbols")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotUpdateDocNameInvalidSymbols() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = "/.:?|\\`\\";
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().updateProperty("cmis:name", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to update folder name with invalid symbols")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisConstraintException.class)
public void siteManagerCannotUpdateFolderNameInvalidSymbols() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
propertyNameValue = "/.:?|\\`\\";
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().updateProperty("cmis:name", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to update document name with empty value")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisRuntimeException.class,
expectedExceptionsMessageRegExp="Local name cannot be null or empty.")
public void siteManagerCannotUpdateDocNameEmptyValue() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().updateProperty("cmis:name", "");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is not able to update folder name with empty value")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisRuntimeException.class,
expectedExceptionsMessageRegExp="Local name cannot be null or empty.")
public void siteManagerCannotUpdateFolderNameEmptyValue() throws Exception
{
testFolder = FolderModel.getRandomFolderModel();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFolder(testFolder).assertThat().existsInRepo()
.then().updateProperty("cmis:name", "");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to update Integer and Long types with max values")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanUpdateIntAndLongTypesWithMaxValue() throws Exception
{
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:tas:document");
properties.put(PropertyIds.NAME, customFile.getName());
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(customFile, properties, VersioningState.MAJOR).assertThat().existsInRepo()
.then().updateProperty("tas:IntPropertyC", Integer.MAX_VALUE)
.and().assertThat().contentPropertyHasValue("tas:IntPropertyC", String.valueOf(Integer.MAX_VALUE))
.then().updateProperty("tas:LongPropertyC", Long.MAX_VALUE)
.and().assertThat().contentPropertyHasValue("tas:LongPropertyC", String.valueOf(Long.MAX_VALUE));
cmisApi.usingResource(customFile).delete().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site manager is able to update Integer and Long types with min values")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void siteManagerCanUpdateIntAndLongTypesWithMinValue() throws Exception
{
FileModel customFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "custom content");
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(PropertyIds.OBJECT_TYPE_ID, "D:tas:document");
properties.put(PropertyIds.NAME, customFile.getName());
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(customFile, properties, VersioningState.MAJOR).assertThat().existsInRepo()
.then().updateProperty("tas:IntPropertyC", Integer.MIN_VALUE)
.and().assertThat().contentPropertyHasValue("tas:IntPropertyC", String.valueOf(Integer.MIN_VALUE))
.then().updateProperty("tas:LongPropertyC", Long.MIN_VALUE)
.and().assertThat().contentPropertyHasValue("tas:LongPropertyC", String.valueOf(Long.MIN_VALUE));
cmisApi.usingResource(customFile).delete().assertThat().doesNotExistInRepo();
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to update properties to a valid document created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanUpdateHisOwnFileProperties() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().updateProperty("cmis:name", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:name", propertyNameValue)
.then().updateProperty("cmis:description", "some description")
.and().assertThat().contentPropertyHasValue("cmis:description", "some description");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to update properties to a valid document created by site manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void collaboratorCanUpdateFilePropertiesCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.and().updateProperty("cmis:name", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:name", propertyNameValue)
.then().updateProperty("cmis:description", "some description")
.and().assertThat().contentPropertyHasValue("cmis:description", "some description");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site contributor is able to update properties to a valid document created by himself")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanUpdateHisOwnFileProperties() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().updateProperty("cmis:name", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:name", propertyNameValue)
.then().updateProperty("cmis:description", "some description")
.and().assertThat().contentPropertyHasValue("cmis:description", "some description");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site collaborator is able to update properties to a valid document created by site manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
public void contributorCanUpdateFilePropertiesCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
.and().updateProperty("cmis:name", propertyNameValue)
.and().assertThat().contentPropertyHasValue("cmis:name", propertyNameValue)
.then().updateProperty("cmis:description", "some description")
.and().assertThat().contentPropertyHasValue("cmis:description", "some description");
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify site consumer is not able to update properties to a valid document created by site manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void consumerCannotUpdateFilePropertiesCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
.and().updateProperty("cmis:name", propertyNameValue);
}
@Bug(id="REPO-4301")
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify disabled user is not able to update properties")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions=CmisUnauthorizedException.class)
public void disabledUserCannotUpdateFileProperties() throws Exception
{
UserModel disabledUser = dataUser.createRandomTestUser();
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(disabledUser).usingShared()
.createFile(testFile).assertThat().existsInRepo();
dataUser.usingAdmin().disableUser(disabledUser);
cmisApi.usingResource(testFile).updateProperty("cmis:name", propertyNameValue);
}
@TestRail(section = {"cmis-api"}, executionType = ExecutionType.REGRESSION,
description = "Verify non invited user is not able to update properties to a document created by site manager")
@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, expectedExceptions={CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
public void nonInvitedUserCannotUpdateFilePropertiesCreatedByManager() throws Exception
{
testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
UserModel nonInvitedUser = dataUser.createRandomTestUser();
propertyNameValue = RandomData.getRandomAlphanumeric();
cmisApi.authenticateUser(testUser).usingSite(testSite)
.createFile(testFile).assertThat().existsInRepo()
.then().authenticateUser(nonInvitedUser)
.and().updateProperty("cmis:name", propertyNameValue);
}
}

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<context:annotation-config />
<context:component-scan base-package="org.alfresco" />
<import resource="classpath:dataprep-context.xml" />
<import resource="classpath*:alfresco-tester-context.xml" />
</beans>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="CMISSuites" parallel="classes" thread-count="1"
preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"/>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"/>
</listeners>
<test name="CMIS Tests">
<packages>
<package name="org.alfresco.cmis"/>
</packages>
</test>
</suite>

View File

@@ -0,0 +1,76 @@
# dataprep related
alfresco.scheme=http
alfresco.server=localhost
alfresco.port=8082
# credentials
admin.user=admin
admin.password=admin
solrWaitTimeInSeconds=30
# in containers we cannot access directly JMX, so we will use http://jolokia.org agent
# disabling this we will use direct JMX calls to server
jmx.useJolokiaAgent=false
# Server Health section
# in ServerHealth#isServerReachable() - could also be shown.
# enable this option to view if on server there are tenants or not
serverHealth.showTenants=true
# set CMIS binding to 'browser' or 'atom'
cmis.binding=browser
cmis.basePath=/alfresco/api/-default-/public/cmis/versions/1.1/${cmis.binding}
# TEST MANAGEMENT SECTION - Test Rail
#
# (currently supporting Test Rail v5.2.1.3472 integration)
#
# Example of configuration:
# ------------------------------------------------------
# if testManagement.enabled=true we enabled TestRailExecutorListener (if used in your suite xml file)
# testManagement.updateTestExecutionResultsOnly=true (this will just update the results of a test: no step will be updated - good for performance)
# testManagement.endPoint=https://alfresco.testrail.com/
# testManagement.username=<username>
# testManagement.apiKey=<api-key>
# testManagement.project=<id-of-your-project
# testManagement.testRun=<test-run-name>
# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false
# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit
# testManagement.suiteId=23 (the id of the Master suite)
# ------------------------------------------------------
testManagement.enabled=false
testManagement.endPoint=
testManagement.username=
testManagement.apiKey=
testManagement.project=7
testManagement.includeOnlyTestCasesExecuted=true
testManagement.rateLimitInSeconds=1
testManagement.testRun=MyTestRunInTestRail
testManagement.suiteId=12
# The location of the reports path
reports.path=./target/reports
#
# Database Section
# You should provide here the database URL, that can be a differed server as alfresco.
# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html
#
# Current supported db.url:
#
# MySQL:
# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
#
# PostgreSQL:
# db.url = jdbc:postgresql://<your-DB-IP>:3306/alfresco
#
# Oracle:
# db.url = jdbc:oracle://<your-DB-IP>:3306/alfresco
#
# MariaDB:
# db.url = jdbc:mariadb://<your-DB-IP>:3306/alfresco
#
db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
db.username = alfresco
db.password = alfresco

View File

@@ -0,0 +1,26 @@
# Root logger option
log4j.rootLogger=INFO, file, stdout
# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=./target/reports/alfresco-tas.log
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%t] %d{HH:mm:ss} %-5p %c{1}:%L - %m%n
# TestRail particular log file
# Direct log messages to a log file
log4j.appender.testrailLog=org.apache.log4j.RollingFileAppender
log4j.appender.testrailLog.File=./target/reports/alfresco-testrail.log
log4j.appender.testrailLog.MaxBackupIndex=10
log4j.appender.testrailLog.layout=org.apache.log4j.PatternLayout
log4j.appender.testrailLog.layout.ConversionPattern=%d{HH:mm:ss} %-5p %c{1}:%L - %m%n
log4j.category.testrail=INFO, testrailLog
log4j.additivity.testrail=false

View File

@@ -0,0 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?>
<model name="tas:cmistasmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Alfresco TAS custom model</description>
<author>Bogdan</author>
<version>1.0</version>
<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>
<namespaces>
<namespace uri="tas.cmis.model" prefix="tas"/>
</namespaces>
<types>
<type name="tas:document">
<title>CMIS TAS Content</title>
<parent>cm:content</parent>
<properties>
<property name="tas:TextPropertyC">
<title>Text</title>
<type>d:text</type>
</property>
<property name="tas:DatePropertyC">
<title>Datetime</title>
<type>d:datetime</type>
</property>
<property name="tas:IntPropertyC">
<title>Integer</title>
<type>d:int</type>
</property>
<property name="tas:LongPropertyC">
<title>Long</title>
<type>d:long</type>
</property>
<property name="tas:MultiplyStringC">
<title>Multiply String</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>true</multiple>
</property>
</properties>
<associations>
<association name="tas:tasContent">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:content</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</type>
<type name="tas:folder">
<title>CMIS TAS Folder</title>
<parent>cm:folder</parent>
<properties>
<property name="tas:TextPropertyF">
<title>Text</title>
<type>d:text</type>
</property>
<property name="tas:DatePropertyF">
<title>Datetime</title>
<type>d:datetime</type>
</property>
<property name="tas:IntPropertyF">
<title>Integer</title>
<type>d:int</type>
</property>
<property name="tas:MultiplyStringF">
<title>Multiply String</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>true</multiple>
</property>
</properties>
<associations>
<association name="tas:tasFolder">
<source>
<mandatory>false</mandatory>
<many>false</many>
</source>
<target>
<class>cm:folder</class>
<mandatory>false</mandatory>
<many>false</many>
</target>
</association>
</associations>
</type>
</types>
<aspects>
<aspect name="tas:tasContentAspect">
<title>TAS Content Aspect</title>
<properties>
<property name="tas:TextPropertyAC">
<title>Aspect Text</title>
<type>d:text</type>
</property>
<property name="tas:DatePropertyAC">
<title>Aspect Datetime</title>
<type>d:datetime</type>
</property>
<property name="tas:IntPropertyAC">
<title>Aspect Integer</title>
<type>d:int</type>
</property>
<property name="tas:MultiplyStringAC">
<title>Aspect Multiply String</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>true</multiple>
</property>
</properties>
</aspect>
<aspect name="tas:tasFolderAspect">
<title>TAS Folder Aspect</title>
<properties>
<property name="tas:TextPropertyAF">
<title>Aspect Text</title>
<type>d:text</type>
</property>
<property name="tas:DatePropertyAF">
<title>Aspect Datetime</title>
<type>d:datetime</type>
</property>
<property name="tas:IntPropertyAF">
<title>Aspect Integer</title>
<type>d:int</type>
</property>
<property name="tas:MultiplyStringAF">
<title>Aspect Multiply String</title>
<type>d:text</type>
<mandatory>true</mandatory>
<multiple>true</multiple>
</property>
</properties>
</aspect>
</aspects>
</model>

View File

@@ -0,0 +1 @@
Sp23xfcYhUBYpsXuPFzn8nVQ