diff --git a/.travis.yml b/.travis.yml
index cae37e3e37..8063f1d9df 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,10 +14,6 @@ cache:
env:
global:
- VERSION_EDITION=Community
- - DOCKER_IMAGE_TAG=latest
- - DOCKER_IMAGE_REGISTRY=quay.io
- - DOCKER_COMPOSE_VERSION=1.23.2
- - ALFRESCO_IMAGE_NAME=alfresco/alfresco-content-repository-community
branches:
only:
@@ -29,13 +25,49 @@ matrix:
# only on master and if it is not a PR
if: fork = false AND branch = master AND type != pull_request
install:
- - travis_retry travis_wait 30 mvn -q install -Dbuild-number=${TRAVIS_BUILD_NUMBER} "-Dbuild-key=${TRAVIS_COMMIT}" "-Dbuild-name=${TRAVIS_BUILD_WEB_URL}" "-Dscm-path=${TRAVIS_REPO_SLUG}" "-Dversion.edition=${VERSION_EDITION}" -f war/pom.xml
+ - travis_retry travis_wait 30 mvn -q install "-Dversion.edition=${VERSION_EDITION}" -f war/pom.xml
script:
# Download the latest version of WhiteSource Unified Agent
- curl -LJO https://github.com/whitesource/unified-agent-distribution/raw/master/standAlone/wss-unified-agent.jar
# Run WhiteSource Unified Agent
- java -jar wss-unified-agent.jar -apiKey ${WHITESOURCE_API_KEY} -c .wss-unified-agent.config -d ./war
- - name: "Build packaging"
- install: skip
+ - name: "REST API TAS tests"
+ jdk: openjdk11
+ install:
+ - travis_retry travis_wait 40 mvn install -q "-Dversion.edition=${VERSION_EDITION}" -Dmaven.javadoc.skip=true -PcommunityDocker
+ - ./tests/scripts/start-compose.sh ./tests/environment/docker-compose-minimal+transforms.yml
+ - ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
script:
- - travis_retry travis_wait 40 mvn install -q -Dbuild-number=${TRAVIS_BUILD_NUMBER} -Dbuild-key=${TRAVIS_COMMIT} -Dbuild-name="${TRAVIS_BUILD_WEB_URL}" -Dscm-path=${TRAVIS_REPO_SLUG} "-Dversion.edition=${VERSION_EDITION}" "-Dimage.tag=${DOCKER_IMAGE_TAG}" -Dimage.registry=${DOCKER_IMAGE_REGISTRY} -Dimage.name=${ALFRESCO_IMAGE_NAME} -Dmaven.javadoc.skip=true -PcommunityDocker
+ - travis_wait 60 mvn install -q -f tests/tas-restapi/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
+ - name: "CMIS TAS tests"
+ jdk: openjdk11
+ install:
+ - travis_retry travis_wait 40 mvn install -q "-Dversion.edition=${VERSION_EDITION}" -Dmaven.javadoc.skip=true -PcommunityDocker
+ - ./tests/scripts/start-compose.sh ./tests/environment/docker-compose-minimal+transforms.yml
+ - ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
+ script:
+ - travis_wait 40 mvn install -q -f tests/tas-cmis/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
+ - name: "Email TAS tests"
+ jdk: openjdk11
+ install:
+ - travis_retry travis_wait 40 mvn install -q "-Dversion.edition=${VERSION_EDITION}" -Dmaven.javadoc.skip=true -PcommunityDocker
+ - ./tests/scripts/start-compose.sh ./tests/environment/docker-compose-minimal.yml
+ - ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
+ script:
+ - travis_wait 30 mvn install -q -f tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
+ - name: "WebDAV TAS tests"
+ jdk: openjdk11
+ install:
+ - travis_retry travis_wait 40 mvn install -q "-Dversion.edition=${VERSION_EDITION}" -Dmaven.javadoc.skip=true -PcommunityDocker
+ - ./tests/scripts/start-compose.sh ./tests/environment/docker-compose-minimal.yml
+ - ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
+ script:
+ - travis_wait 30 mvn install -q -f tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
+ - name: "Integration TAS tests"
+ jdk: openjdk11
+ install:
+ - travis_retry travis_wait 40 mvn install -q "-Dversion.edition=${VERSION_EDITION}" -Dmaven.javadoc.skip=true -PcommunityDocker
+ - ./tests/scripts/start-compose.sh ./tests/environment/docker-compose-minimal.yml
+ - ./tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco"
+ script:
+ - travis_wait 30 mvn install -q -f tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false
diff --git a/docker-alfresco/test/docker-compose.yml b/docker-alfresco/test/docker-compose.yml
index baaa309091..af6dc3e519 100644
--- a/docker-alfresco/test/docker-compose.yml
+++ b/docker-alfresco/test/docker-compose.yml
@@ -54,8 +54,8 @@ services:
- 8082:8080
- 8000:8000
- 143:1143
- - "21:1221"
- - "30000-30099:30000-30099"
+ - 21:1221
+ - 30000-30099:30000-30099
alfresco-pdf-renderer:
image: alfresco/alfresco-pdf-renderer:${TRANSFORMERS_TAG}
@@ -106,8 +106,6 @@ services:
- POSTGRES_PASSWORD=alfresco
- POSTGRES_USER=alfresco
- POSTGRES_DB=alfresco
- ports:
- - 5432:5432
solr6:
image: alfresco/alfresco-search-services:${SOLR6_TAG}
diff --git a/pom.xml b/pom.xml
index c727b4cb1d..d737ad6215 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,12 @@
docker-alfresco
+
+ all-tas-tests
+
+ tests
+
+
@@ -101,6 +107,15 @@
42.2.6
+ 3.0.14
+ 3.3.0
+ 1.0.4
+ 1.15
+ 1.5
+ 1.1
+ 1.0
+ 1.0
+ 2.2
diff --git a/tests/environment/.env b/tests/environment/.env
new file mode 100644
index 0000000000..ef18cd66ba
--- /dev/null
+++ b/tests/environment/.env
@@ -0,0 +1,4 @@
+TRANSFORMERS_TAG=2.1.0
+SOLR6_TAG=1.4.0
+POSTGRES_TAG=11.4
+ACTIVEMQ_TAG=5.15.8
diff --git a/tests/environment/docker-compose-minimal+transforms.yml b/tests/environment/docker-compose-minimal+transforms.yml
new file mode 100644
index 0000000000..2de93ab468
--- /dev/null
+++ b/tests/environment/docker-compose-minimal+transforms.yml
@@ -0,0 +1,143 @@
+version: "3"
+
+# The acs-community-deployment project contains the product version of docker-compose.
+#
+# This version is for testing and development use. For testing and debug we need to have a more open version.
+# For remote debug we need the CATALINA_OPTS and to expose port 8000.
+
+services:
+ alfresco:
+ image: alfresco/alfresco-content-repository-community:latest
+ environment:
+ CATALINA_OPTS : "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
+ JAVA_OPTS :
+ "
+ -Ddb.driver=org.postgresql.Driver
+ -Ddb.username=alfresco
+ -Ddb.password=alfresco
+ -Ddb.url=jdbc:postgresql://postgres:5432/alfresco
+ -Dsolr.host=solr6
+ -Dsolr.port=8983
+ -Dsolr.secureComms=none
+ -Dsolr.base.url=/solr
+ -Dindex.subsystem.name=solr6
+ -Dalfresco.restApi.basicAuthScheme=true
+ -Dimap.server.enabled=true
+ -Dftp.enabled=true
+ -Dftp.dataPortFrom=30000
+ -Dftp.dataPortTo=30099
+ -Dshare.host=localhost
+ -Daos.baseUrlOverwrite=http://localhost:8082/alfresco/aos
+ -Dmessaging.broker.url=\"failover:(tcp://activemq:61616)?timeout=3000&jms.useCompression=true\"
+
+ -Dlocal.transform.service.enabled=true
+ -DlocalTransform.pdfrenderer.url=http://alfresco-pdf-renderer:8090/
+ -DlocalTransform.imagemagick.url=http://imagemagick:8090/
+ -DlocalTransform.libreoffice.url=http://libreoffice:8090/
+ -DlocalTransform.tika.url=http://tika:8090/
+ -DlocalTransform.misc.url=http://transform-misc:8090/
+
+ -Dlegacy.transform.service.enabled=true
+ -Dalfresco-pdf-renderer.url=http://alfresco-pdf-renderer:8090/
+ -Djodconverter.url=http://libreoffice:8090/
+ -Dimg.url=http://imagemagick:8090/
+ -Dtika.url=http://tika:8090/
+ -Dtransform.misc.url=http://transform-misc:8090/
+
+ -Dimap.server.port=1143
+ -Dftp.port=1221
+ -Dcors.enabled=true
+ -Dcors.allowed.origins=http://localhost:4200
+ "
+ ports:
+ - 8082:8080
+ - 8000:8000
+ - 143:1143
+ - 21:1221
+ - 30000-30099:30000-30099
+
+ postgres:
+ image: library/postgres:${POSTGRES_TAG}
+ environment:
+ - POSTGRES_PASSWORD=alfresco
+ - POSTGRES_USER=alfresco
+ - POSTGRES_DB=alfresco
+
+ solr6:
+ image: alfresco/alfresco-search-services:${SOLR6_TAG}
+ environment:
+ #Solr needs to know how to register itself with Alfresco
+ - SOLR_ALFRESCO_HOST=alfresco
+ - SOLR_ALFRESCO_PORT=8080
+ #Alfresco needs to know how to call solr
+ - SOLR_SOLR_HOST=solr6
+ - SOLR_SOLR_PORT=8983
+ #Create the default alfresco and archive cores
+ - SOLR_CREATE_ALFRESCO_DEFAULTS=alfresco,archive
+ #HTTP by default
+ - ALFRESCO_SECURE_COMMS=none
+ ports:
+ - 8083:8983 #Browser port
+
+ activemq:
+ image: alfresco/alfresco-activemq:${ACTIVEMQ_TAG}
+ ports:
+ - 8161:8161 # Web Console
+ - 5672:5672 # AMQP
+ - 61616:61616 # OpenWire
+ - 61613:61613 # STOMP
+
+ alfresco-pdf-renderer:
+ image: alfresco/alfresco-pdf-renderer:${TRANSFORMERS_TAG}
+ environment:
+ JAVA_OPTS: " -Xms256m -Xmx256m"
+ ACTIVEMQ_URL: "nio://activemq:61616"
+ ACTIVEMQ_USER: "admin"
+ ACTIVEMQ_PASSWORD: "admin"
+ FILE_STORE_URL: "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file"
+ ports:
+ - 8090:8090
+
+ imagemagick:
+ image: alfresco/alfresco-imagemagick:${TRANSFORMERS_TAG}
+ environment:
+ JAVA_OPTS: " -Xms256m -Xmx256m"
+ ACTIVEMQ_URL: "nio://activemq:61616"
+ ACTIVEMQ_USER: "admin"
+ ACTIVEMQ_PASSWORD: "admin"
+ FILE_STORE_URL: "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file"
+ ports:
+ - 8091:8090
+
+ libreoffice:
+ image: alfresco/alfresco-libreoffice:${TRANSFORMERS_TAG}
+ environment:
+ JAVA_OPTS: " -Xms256m -Xmx256m"
+ ACTIVEMQ_URL: "nio://activemq:61616"
+ ACTIVEMQ_USER: "admin"
+ ACTIVEMQ_PASSWORD: "admin"
+ FILE_STORE_URL: "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file"
+ ports:
+ - 8092:8090
+
+ tika:
+ image: alfresco/alfresco-tika:${TRANSFORMERS_TAG}
+ environment:
+ JAVA_OPTS: " -Xms256m -Xmx256m"
+ ACTIVEMQ_URL: "nio://activemq:61616"
+ FILE_STORE_URL: "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file"
+ ACTIVEMQ_USER: "admin"
+ ACTIVEMQ_PASSWORD: "admin"
+ ports:
+ - 8093:8090
+
+ transform-misc:
+ image: alfresco/alfresco-transform-misc:${TRANSFORMERS_TAG}
+ environment:
+ JAVA_OPTS: " -Xms256m -Xmx256m"
+ ACTIVEMQ_URL: "nio://activemq:61616"
+ ACTIVEMQ_USER: "admin"
+ ACTIVEMQ_PASSWORD: "admin"
+ FILE_STORE_URL: "http://shared-file-store:8099/alfresco/api/-default-/private/sfs/versions/1/file"
+ ports:
+ - 8094:8090
diff --git a/tests/environment/docker-compose-minimal.yml b/tests/environment/docker-compose-minimal.yml
new file mode 100644
index 0000000000..453db3ae8b
--- /dev/null
+++ b/tests/environment/docker-compose-minimal.yml
@@ -0,0 +1,77 @@
+version: "3"
+
+# The acs-community-deployment project contains the product version of docker-compose.
+#
+# This version is for testing and development use. For testing and debug we need to have a more open version.
+# For remote debug we need the CATALINA_OPTS and to expose port 8000.
+
+services:
+ alfresco:
+ image: alfresco/alfresco-content-repository-community:latest
+ environment:
+ CATALINA_OPTS : "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
+ JAVA_OPTS :
+ "
+ -Ddb.driver=org.postgresql.Driver
+ -Ddb.username=alfresco
+ -Ddb.password=alfresco
+ -Ddb.url=jdbc:postgresql://postgres:5432/alfresco
+ -Dsolr.host=solr6
+ -Dsolr.port=8983
+ -Dsolr.secureComms=none
+ -Dsolr.base.url=/solr
+ -Dindex.subsystem.name=solr6
+ -Dalfresco.restApi.basicAuthScheme=true
+ -Dimap.server.enabled=true
+ -Dftp.enabled=true
+ -Dftp.dataPortFrom=30000
+ -Dftp.dataPortTo=30099
+ -Dshare.host=localhost
+ -Daos.baseUrlOverwrite=http://localhost:8082/alfresco/aos
+ -Dmessaging.broker.url=\"failover:(tcp://activemq:61616)?timeout=3000&jms.useCompression=true\"
+
+ -Dlocal.transform.service.enabled=false
+ -Dlegacy.transform.service.enabled=false
+
+ -Dimap.server.port=1143
+ -Dftp.port=1221
+ -Dcors.enabled=true
+ -Dcors.allowed.origins=http://localhost:4200
+ "
+ ports:
+ - 8082:8080
+ - 8000:8000
+ - 143:1143
+ - 21:1221
+ - 30000-30099:30000-30099
+
+ postgres:
+ image: library/postgres:${POSTGRES_TAG}
+ environment:
+ - POSTGRES_PASSWORD=alfresco
+ - POSTGRES_USER=alfresco
+ - POSTGRES_DB=alfresco
+
+ solr6:
+ image: alfresco/alfresco-search-services:${SOLR6_TAG}
+ environment:
+ #Solr needs to know how to register itself with Alfresco
+ - SOLR_ALFRESCO_HOST=alfresco
+ - SOLR_ALFRESCO_PORT=8080
+ #Alfresco needs to know how to call solr
+ - SOLR_SOLR_HOST=solr6
+ - SOLR_SOLR_PORT=8983
+ #Create the default alfresco and archive cores
+ - SOLR_CREATE_ALFRESCO_DEFAULTS=alfresco,archive
+ #HTTP by default
+ - ALFRESCO_SECURE_COMMS=none
+ ports:
+ - 8083:8983 #Browser port
+
+ activemq:
+ image: alfresco/alfresco-activemq:${ACTIVEMQ_TAG}
+ ports:
+ - 8161:8161 # Web Console
+ - 5672:5672 # AMQP
+ - 61616:61616 # OpenWire
+ - 61613:61613 # STOMP
\ No newline at end of file
diff --git a/tests/pom.xml b/tests/pom.xml
new file mode 100644
index 0000000000..80692a107b
--- /dev/null
+++ b/tests/pom.xml
@@ -0,0 +1,86 @@
+
+ 4.0.0
+ content-repository-community-tas-tests-parent
+ 6.3.0-SNAPSHOT
+ pom
+
+
+ org.alfresco
+ acs-community-packaging
+ 6.3.0-SNAPSHOT
+ ../pom.xml
+
+
+
+ tas-restapi
+ tas-cmis
+ tas-email
+ tas-webdav
+ tas-integration
+
+
+
+
+
+ org.alfresco.tas
+ utility
+ ${dependency.tas-utility.version}
+ test
+
+
+ io.rest-assured
+ rest-assured
+ ${dependency.rest-assured.version}
+ test
+
+
+ org.glassfish
+ javax.json
+ ${dependency.javax.json.version}
+ test
+
+
+ org.alfresco.tas
+ restapi
+ ${dependency.tas-restapi.version}
+ test
+
+
+ org.alfresco.tas
+ cmis
+ ${dependency.tas-cmis.version}
+ test
+
+
+ org.alfresco.tas
+ email
+ ${dependency.tas-email.version}
+ test
+
+
+ org.alfresco.tas
+ webdav
+ ${dependency.tas-webdav.version}
+ test
+
+
+ org.alfresco.tas
+ ftp
+ ${dependency.tas-ftp.version}
+ test
+
+
+ org.alfresco.test
+ dataprep
+ ${dependency.tas-dataprep.version}
+ test
+
+
+ org.springframework
+ spring-test
+ ${dependency.spring.version}
+ test
+
+
+
+
\ No newline at end of file
diff --git a/tests/scripts/start-compose.sh b/tests/scripts/start-compose.sh
new file mode 100755
index 0000000000..ace065bb0c
--- /dev/null
+++ b/tests/scripts/start-compose.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+export DOCKER_COMPOSE_PATH=$1
+
+if [ -z "$DOCKER_COMPOSE_PATH" ]
+then
+ echo "Please provide path to docker-compose.yml: \"${0##*/} /path/to/docker-compose.yml\""
+ exit 1
+fi
+
+echo "Starting ACS stack in ${DOCKER_COMPOSE_PATH}"
+
+# .env files are picked up from project directory correctly on docker-compose 1.23.0+
+docker-compose --file "${DOCKER_COMPOSE_PATH}" --project-directory $(dirname "${DOCKER_COMPOSE_PATH}") up -d
+
+if [ $? -eq 0 ]
+then
+ echo "Docker Compose started ok"
+else
+ echo "Docker Compose failed to start" >&2
+ exit 1
+fi
\ No newline at end of file
diff --git a/tests/scripts/stop-compose.sh b/tests/scripts/stop-compose.sh
new file mode 100755
index 0000000000..6fe5738624
--- /dev/null
+++ b/tests/scripts/stop-compose.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+export DOCKER_COMPOSE_PATH=$1
+
+if [ -z "$DOCKER_COMPOSE_PATH" ]
+then
+ echo "Please provide path to docker-compose.yml: \"${0##*/} /path/to/docker-compose.yml\""
+ exit 1
+fi
+
+echo "Killing ACS stack in ${DOCKER_COMPOSE_PATH}"
+
+cd ${DOCKER_COMPOSE_PATH}
+
+docker-compose ps
+# logs for debug
+docker-compose logs --no-color -t alfresco
+docker-compose kill
+docker-compose rm -fv
\ No newline at end of file
diff --git a/tests/scripts/wait-for-alfresco-start.sh b/tests/scripts/wait-for-alfresco-start.sh
new file mode 100755
index 0000000000..df48191306
--- /dev/null
+++ b/tests/scripts/wait-for-alfresco-start.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+export ALFRESCO_URL=$1
+
+if [ -z "$ALFRESCO_URL" ]
+then
+ echo "Please provide the Alfresco URL to check, for example: \"${0##*/} http://localhost:8080/alfresco\""
+ exit 1
+fi
+
+WAIT_INTERVAL=1
+COUNTER=0
+TIMEOUT=300
+t0=$(date +%s)
+
+echo "Waiting for alfresco to start"
+until $(curl --output /dev/null --silent --head --fail ${ALFRESCO_URL}) || [ "$COUNTER" -eq "$TIMEOUT" ]; do
+ printf '.'
+ sleep $WAIT_INTERVAL
+ COUNTER=$(($COUNTER+$WAIT_INTERVAL))
+done
+
+if (("$COUNTER" < "$TIMEOUT")) ; then
+ t1=$(date +%s)
+ delta=$((($t1 - $t0)/60))
+ echo "Alfresco Started in $delta minutes"
+else
+ echo "Waited $COUNTER seconds"
+ echo "Alfresco Could not start in time."
+ exit 1
+fi
\ No newline at end of file
diff --git a/tests/tas-cmis/pom.xml b/tests/tas-cmis/pom.xml
new file mode 100644
index 0000000000..6b5f6175a6
--- /dev/null
+++ b/tests/tas-cmis/pom.xml
@@ -0,0 +1,66 @@
+
+
+ 4.0.0
+ org.alfresco.tas
+ content-repository-community-cmis-test
+ content-repository-community-cmis-test
+ 6.3.0-SNAPSHOT
+ jar
+
+
+ org.alfresco
+ content-repository-community-tas-tests-parent
+ 6.3.0-SNAPSHOT
+ ../pom.xml
+
+
+
+
+ Paul Brodner
+
+ Test Automation Architect
+
+
+
+
+
+ ${project.basedir}/src/test/resources/cmis-suite.xml
+
+
+
+
+ org.alfresco.tas
+ cmis
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ ${suiteXmlFile}
+
+
+ --illegal-access=warn
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/AclTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AclTests.java
new file mode 100644
index 0000000000..ed372303ca
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AclTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/AddObjectToFolderTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AddObjectToFolderTests.java
new file mode 100644
index 0000000000..558e46ee58
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AddObjectToFolderTests.java
@@ -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);
+ }
+}
+
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/AllowableActionTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AllowableActionTests.java
new file mode 100644
index 0000000000..3047a32441
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AllowableActionTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/AppendContentStreamTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AppendContentStreamTests.java
new file mode 100644
index 0000000000..1cc3f5b753
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/AppendContentStreamTests.java
@@ -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);
+ }
+
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CancelCheckOutTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CancelCheckOutTests.java
new file mode 100644
index 0000000000..55f1971607
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CancelCheckOutTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CheckInTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CheckInTests.java
new file mode 100644
index 0000000000..4caa9fddef
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CheckInTests.java
@@ -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.waitToLoopTime(5);
+ 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 properties = new HashMap();
+ 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 properties = new HashMap();
+ 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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CheckOutTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CheckOutTests.java
new file mode 100644
index 0000000000..95affaa4ca
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CheckOutTests.java
@@ -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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CmisTest.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CmisTest.java
new file mode 100644
index 0000000000..cf83810ce9
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CmisTest.java
@@ -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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CopyTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CopyTests.java
new file mode 100644
index 0000000000..668c52c039
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CopyTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateDocumentFromSourceTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateDocumentFromSourceTests.java
new file mode 100644
index 0000000000..b04eb10425
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateDocumentFromSourceTests.java
@@ -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(500, 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(500, 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(500, 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(500, 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(500, 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(1000, 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(1000, 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);
+ }
+
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateDocumentTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateDocumentTests.java
new file mode 100644
index 0000000000..c212824ec2
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateDocumentTests.java
@@ -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 properties = new HashMap();
+ 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);
+ }
+
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateFolderTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateFolderTests.java
new file mode 100644
index 0000000000..8674321502
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/CreateFolderTests.java
@@ -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 properties = new HashMap();
+ 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 properties = new HashMap();
+ 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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/DataListsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DataListsTests.java
new file mode 100644
index 0000000000..fec6d4b7fc
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DataListsTests.java
@@ -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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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 itemProperties = new HashMap();
+ 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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteAllVersionsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteAllVersionsTests.java
new file mode 100644
index 0000000000..8beaee73bb
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteAllVersionsTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteContentStreamTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteContentStreamTests.java
new file mode 100644
index 0000000000..04ea6091dc
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteContentStreamTests.java
@@ -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();
+ }
+
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteTests.java
new file mode 100644
index 0000000000..a9a63e7eef
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteTests.java
@@ -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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteTreeTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteTreeTests.java
new file mode 100644
index 0000000000..f1c0b0dd08
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/DeleteTreeTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetAllVersionsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetAllVersionsTests.java
new file mode 100644
index 0000000000..f9a948b29b
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetAllVersionsTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetCheckedOutDocumentsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetCheckedOutDocumentsTests.java
new file mode 100644
index 0000000000..0d49f2f5c0
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetCheckedOutDocumentsTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetChildrenTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetChildrenTests.java
new file mode 100644
index 0000000000..9716ae6440
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetChildrenTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetContentStreamTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetContentStreamTests.java
new file mode 100644
index 0000000000..5de39f2026
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetContentStreamTests.java
@@ -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);
+ }
+
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetDescendantsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetDescendantsTests.java
new file mode 100644
index 0000000000..043e3b20c4
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetDescendantsTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetExtensionTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetExtensionTests.java
new file mode 100644
index 0000000000..83ac7bd406
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetExtensionTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetFolderParentTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetFolderParentTests.java
new file mode 100644
index 0000000000..946b8c7e21
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetFolderParentTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetFolderTreeTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetFolderTreeTests.java
new file mode 100644
index 0000000000..93f389b707
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetFolderTreeTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetObjectOfLatestVersionTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetObjectOfLatestVersionTests.java
new file mode 100644
index 0000000000..a230df2d39
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetObjectOfLatestVersionTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetObjectTypeTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetObjectTypeTests.java
new file mode 100644
index 0000000000..bf5d3a2057
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetObjectTypeTests.java
@@ -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());
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetParentsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetParentsTests.java
new file mode 100644
index 0000000000..49b67b613a
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetParentsTests.java
@@ -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());
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetPropertiesTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetPropertiesTests.java
new file mode 100644
index 0000000000..6503983bf2
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetPropertiesTests.java
@@ -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");
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeChildrenTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeChildrenTests.java
new file mode 100644
index 0000000000..9a7fe34fca
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeChildrenTests.java
@@ -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> 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> 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> 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> 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> 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");
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeDefinitionTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeDefinitionTests.java
new file mode 100644
index 0000000000..ed6097558f
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeDefinitionTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeDescendantsTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeDescendantsTests.java
new file mode 100644
index 0000000000..cf897a8546
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/GetTypeDescendantsTests.java
@@ -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> 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> 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> 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> 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> 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> 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");
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/IsLatestMajorVersionTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/IsLatestMajorVersionTests.java
new file mode 100644
index 0000000000..d5fdb7b46a
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/IsLatestMajorVersionTests.java
@@ -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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/IsPrivateWorkingCopyTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/IsPrivateWorkingCopyTests.java
new file mode 100644
index 0000000000..e7ea845023
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/IsPrivateWorkingCopyTests.java
@@ -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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/MoveTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/MoveTests.java
new file mode 100644
index 0000000000..b6f9fccc19
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/MoveTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/RelationshipTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RelationshipTests.java
new file mode 100644
index 0000000000..d5662fafeb
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RelationshipTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/RemoveObjectFromFolderTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RemoveObjectFromFolderTests.java
new file mode 100644
index 0000000000..9d164edca6
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RemoveObjectFromFolderTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/RenameTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RenameTests.java
new file mode 100644
index 0000000000..a7206e8388
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RenameTests.java
@@ -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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/RenditionTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RenditionTests.java
new file mode 100644
index 0000000000..5f4a03f9d8
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RenditionTests.java
@@ -0,0 +1,168 @@
+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;
+
+@Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS, TestGroup.RENDITIONS})
+public class RenditionTests extends CmisTest
+{
+ SiteModel testSite;
+ UserModel testUser, inexistentUser, nonInvitedUser;
+ FileModel testFile;
+ private DataUser.ListUserWithRoles usersWithRoles;
+
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, documentContent);
+ 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);
+ cmisApi.authenticateUser(testUser).usingSite(testSite)
+ .createFile(testFile).assertThat().existsInRepo();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
+ @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)
+ .then().usingResource(txtModel).assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, 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})
+ @TestRail(section = {"cmis-api"}, executionType= ExecutionType.SANITY,
+ description = "Verify site manager can get renditions for valid Document")
+ public void managerGetRenditionsForDocument() throws Exception
+ {
+ cmisApi.authenticateUser(testUser)
+ .usingResource(testFile).assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
+ @TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
+ description = "Verify site collaborator can get renditions for valid Document")
+ public void collaboratorGetRenditionsForDocument() throws Exception
+ {
+ cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
+ .usingResource(testFile).assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
+ @TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
+ description = "Verify site contributor can get renditions for valid Document")
+ public void contributorGetRenditionsForDocument() throws Exception
+ {
+ cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
+ .usingResource(testFile).assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
+ @TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
+ description = "Verify site consumer can get renditions for valid Document")
+ public void consumerGetRenditionsForDocument() throws Exception
+ {
+ cmisApi.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
+ .usingResource(testFile).assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
+ @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()
+ .usingResource(checkedDoc)
+ .assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS})
+ @TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
+ description = "Verify non invited user can get renditions in public site")
+ public void nonInvitedUserGetRenditionsInPublicSite() throws Exception
+ {
+ cmisApi.authenticateUser(nonInvitedUser)
+ .usingResource(testFile)
+ .assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+
+ @Test(groups = { TestGroup.REGRESSION, TestGroup.CMIS}, 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}, 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}, expectedExceptions=CmisUnauthorizedException.class)
+ @TestRail(section = {"cmis-api"}, executionType= ExecutionType.REGRESSION,
+ description = "Verify inexistent user cannot get renditions")
+ public void inexistentUserCannotGetRenditions() throws Exception
+ {
+ cmisApi.authenticateUser(inexistentUser)
+ .usingResource(testFile)
+ .assertThat().renditionIsAvailable()
+ .assertThat().thumbnailRenditionIsAvailable();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/RepositoryInfoTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RepositoryInfoTests.java
new file mode 100644
index 0000000000..8a24cb496f
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/RepositoryInfoTests.java
@@ -0,0 +1,118 @@
+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.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 = {NoSuchMethodError.class}, expectedExceptionsMessageRegExp = "^org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException.*")
+ @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();
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/SecondaryTypesTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/SecondaryTypesTests.java
new file mode 100644
index 0000000000..121bd2dab4
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/SecondaryTypesTests.java
@@ -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");
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/SetContentTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/SetContentTests.java
new file mode 100644
index 0000000000..7ceada39ae
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/SetContentTests.java
@@ -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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/java/org/alfresco/cmis/UpdatePropertiesTests.java b/tests/tas-cmis/src/test/java/org/alfresco/cmis/UpdatePropertiesTests.java
new file mode 100644
index 0000000000..da87ca47f6
--- /dev/null
+++ b/tests/tas-cmis/src/test/java/org/alfresco/cmis/UpdatePropertiesTests.java
@@ -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 properties = new HashMap();
+ 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 properties = new HashMap();
+ 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);
+ }
+}
diff --git a/tests/tas-cmis/src/test/resources/alfresco-cmis-context.xml b/tests/tas-cmis/src/test/resources/alfresco-cmis-context.xml
new file mode 100644
index 0000000000..ecf3d2db4b
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/alfresco-cmis-context.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/tas-cmis/src/test/resources/cmis-suite.xml b/tests/tas-cmis/src/test/resources/cmis-suite.xml
new file mode 100644
index 0000000000..46728ee4e4
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/cmis-suite.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-cmis/src/test/resources/default.properties b/tests/tas-cmis/src/test/resources/default.properties
new file mode 100644
index 0000000000..9ca9119ba5
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/default.properties
@@ -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=
+# testManagement.apiKey=
+# testManagement.project=
+# 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://:3306/alfresco
+#
+# Oracle:
+# db.url = jdbc:oracle://:3306/alfresco
+#
+# MariaDB:
+# db.url = jdbc:mariadb://:3306/alfresco
+#
+db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
+db.username = alfresco
+db.password = alfresco
diff --git a/tests/tas-cmis/src/test/resources/log4j.properties b/tests/tas-cmis/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..00e9b5a114
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/log4j.properties
@@ -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
\ No newline at end of file
diff --git a/tests/tas-cmis/src/test/resources/shared-resources/model/tas-model.xml b/tests/tas-cmis/src/test/resources/shared-resources/model/tas-model.xml
new file mode 100644
index 0000000000..892027f9c1
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/shared-resources/model/tas-model.xml
@@ -0,0 +1,151 @@
+
+
+
+
+ Alfresco TAS custom model
+ Bogdan
+ 1.0
+
+
+
+
+
+
+
+
+
+
+
+
+ CMIS TAS Content
+ cm:content
+
+
+ Text
+ d:text
+
+
+ Datetime
+ d:datetime
+
+
+ Integer
+ d:int
+
+
+ Long
+ d:long
+
+
+ Multiply String
+ d:text
+ true
+ true
+
+
+
+
+
+
+ false
+ false
+
+
+ cm:content
+ false
+ false
+
+
+
+
+
+
+ CMIS TAS Folder
+ cm:folder
+
+
+ Text
+ d:text
+
+
+ Datetime
+ d:datetime
+
+
+ Integer
+ d:int
+
+
+ Multiply String
+ d:text
+ true
+ true
+
+
+
+
+
+
+ false
+ false
+
+
+ cm:folder
+ false
+ false
+
+
+
+
+
+
+
+
+ TAS Content Aspect
+
+
+ Aspect Text
+ d:text
+
+
+ Aspect Datetime
+ d:datetime
+
+
+ Aspect Integer
+ d:int
+
+
+ Aspect Multiply String
+ d:text
+ true
+ true
+
+
+
+
+
+ TAS Folder Aspect
+
+
+ Aspect Text
+ d:text
+
+
+ Aspect Datetime
+ d:datetime
+
+
+ Aspect Integer
+ d:int
+
+
+ Aspect Multiply String
+ d:text
+ true
+ true
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-cmis/src/test/resources/shared-resources/testdata/cmis-checkIn.txt b/tests/tas-cmis/src/test/resources/shared-resources/testdata/cmis-checkIn.txt
new file mode 100644
index 0000000000..863a223b69
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/shared-resources/testdata/cmis-checkIn.txt
@@ -0,0 +1 @@
+Sp23xfcYhUBYpsXuPFzn8nVQ
\ No newline at end of file
diff --git a/tests/tas-cmis/src/test/resources/shared-resources/testdata/cmis-resource b/tests/tas-cmis/src/test/resources/shared-resources/testdata/cmis-resource
new file mode 100644
index 0000000000..e01d809153
--- /dev/null
+++ b/tests/tas-cmis/src/test/resources/shared-resources/testdata/cmis-resource
@@ -0,0 +1 @@
+tas
\ No newline at end of file
diff --git a/tests/tas-email/pom.xml b/tests/tas-email/pom.xml
new file mode 100644
index 0000000000..b8734067ae
--- /dev/null
+++ b/tests/tas-email/pom.xml
@@ -0,0 +1,66 @@
+
+
+ 4.0.0
+ org.alfresco.tas
+ content-repository-community-email-test
+ content-repository-community-email-test
+ 6.3.0-SNAPSHOT
+ jar
+
+
+ org.alfresco
+ content-repository-community-tas-tests-parent
+ 6.3.0-SNAPSHOT
+ ../pom.xml
+
+
+
+
+ Paul Brodner
+
+ Test Automation Architect
+
+
+
+
+
+ ${project.basedir}/src/test/resources/email-suite.xml
+
+
+
+
+ org.alfresco.tas
+ email
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ ${suiteXmlFile}
+
+
+ --illegal-access=warn
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java b/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java
new file mode 100644
index 0000000000..2a1a1b4a58
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java
@@ -0,0 +1,100 @@
+package org.alfresco.email;
+
+import java.lang.reflect.Method;
+
+import org.alfresco.email.dsl.ServerConfiguration;
+import org.alfresco.utility.LogFactory;
+import org.alfresco.utility.data.*;
+import org.alfresco.utility.model.*;
+import org.alfresco.utility.network.ServerHealth;
+import org.alfresco.utility.network.TenantConsole;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
+import org.testng.annotations.*;
+
+@ContextConfiguration("classpath:alfresco-email-context.xml")
+public abstract class EmailTest extends AbstractTestNGSpringContextTests
+{
+ private static Logger LOG = LogFactory.getLogger();
+
+ @Autowired
+ ServerHealth serverHealth;
+
+ @Autowired
+ protected ImapWrapper imapProtocol;
+
+ @Autowired
+ protected SmtpWrapper smtpProtocol;
+
+ @Autowired
+ public DataUser dataUser;
+
+ @Autowired
+ public DataGroup dataGroup;
+
+ @Autowired
+ public DataSite dataSite;
+
+ @Autowired
+ public DataContent dataContent;
+
+ @Autowired
+ public DataLink dataLink;
+
+ @Autowired
+ public DataCalendarEvent dataCalendarEvent;
+
+ @Autowired
+ public DataWiki dataWiki;
+
+ @Autowired
+ public TenantConsole tenantConsole;
+
+ protected UserModel adminUser;
+ protected UserModel testUser;
+ protected SiteModel adminSite;
+ protected SiteModel testSite;
+ protected FolderModel testFolder;
+ protected FileModel testFile;
+ protected ContentModel contentModel;
+
+ @BeforeSuite(alwaysRun = true)
+ public void checkServerHealth() throws Exception
+ {
+ super.springTestContextPrepareTestInstance();
+ serverHealth.assertServerIsOnline();
+
+ UserModel anonymousUser = new UserModel("anonymous", DataUser.PASSWORD);
+ if (!dataUser.isUserInRepo(anonymousUser.getUsername()))
+ {
+ dataUser.createUser(anonymousUser);
+ dataGroup.usingUser(anonymousUser).addUserToGroup(GroupModel.getEmailContributorsGroup());
+ }
+
+ String jmxUseJolokiaAgent = System.getProperty("jmx.useJolokiaAgent");
+ if ("true".equals(jmxUseJolokiaAgent))
+ {
+ imapProtocol.assertThat().protocolIsEnabled();
+ smtpProtocol.assertThat().protocolIsEnabled();
+ ServerConfiguration.save(smtpProtocol.withJMX(), smtpProtocol.emailProperties);
+ }
+ else
+ {
+ LOG.warn("*** Jolokia is not used! To use jolokia, please add next system property when running the tests: jmx.useJolokiaAgent=true ***");
+ }
+ }
+
+ @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()));
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCheckFolderTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCheckFolderTests.java
new file mode 100644
index 0000000000..d99b21dad7
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCheckFolderTests.java
@@ -0,0 +1,189 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.FolderNotFoundException;
+import javax.mail.MessagingException;
+
+public class ImapCheckFolderTests extends EmailTest
+{
+ UserModel managerUser;
+ SiteModel managerTestSite;
+
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ managerUser = dataUser.createRandomTestUser();
+ managerTestSite = dataSite.usingUser(managerUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Returns the current working directory with admin user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldGetCurrentWorkingDirectory() throws Exception
+ {
+ testUser = dataUser.getAdminUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).assertThat().existsInRepo()
+ .then().assertThat().currentDirectoryIs(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify in IMAP client current directory/list of directories for site manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldGetCurrentWorkingDirectory() throws Exception
+ {
+ testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
+ imapProtocol.authenticateUser(managerUser).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
+ .then().assertThat().currentDirectoryIs(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Returns the directories list of the root for site manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldGetDirectoriesListOfRoot() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ FolderModel alfrescoImap = FolderModel.getRandomFolderModel();
+ alfrescoImap.setName("Alfresco IMAP");
+ FolderModel inbox = FolderModel.getRandomFolderModel();
+ inbox.setName("INBOX");
+ imapProtocol.authenticateUser(testUser).usingRoot()
+ .then().assertThat().contains(alfrescoImap, inbox);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "User finds all its folders for IMAP Sites in Alfresco IMAP > Sites folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void userShouldFindAllIMAPSitesFoldersInAlfrescoIMAPFolder() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ SiteModel imapSite1 = dataSite.usingUser(testUser).createIMAPSite();
+ SiteModel imapSite2 = dataSite.usingUser(testUser).createIMAPSite();
+
+ imapProtocol.authenticateUser(testUser).usingSites().assertThat().existsInImap()
+ .then().assertThat().contains(imapSite1, imapSite2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify in IMAP client current directory/list of directories for COLLABORATOR user - folder created by other user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void collaboratorShouldGetCurrentWorkingDirectory() throws Exception
+ {
+ UserModel collaborator = dataUser.createRandomTestUser();
+ dataUser.usingUser(managerUser).addUserToSite(collaborator, managerTestSite, UserRole.SiteCollaborator);
+
+ testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
+ imapProtocol.authenticateUser(collaborator).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
+ .then().assertThat().currentDirectoryIs(testFolder);
+
+ dataSite.usingUser(collaborator).usingSite(managerTestSite).setIMAPFavorite();
+
+ FolderModel testFolder1 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
+ .usingResource(testFolder).createFolder();
+ FolderModel testFolder2 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
+ .usingResource(testFolder).createFolder();
+
+ imapProtocol.authenticateUser(collaborator).usingSite(managerTestSite)
+ .usingResource(testFolder)
+ .then().assertThat().contains(testFolder1,testFolder2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify in IMAP client current directory/list of directories for CONTRIBUTOR user - folder created by other user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void contributorShouldGetCurrentWorkingDirectory() throws Exception
+ {
+ UserModel contributor = dataUser.createRandomTestUser();
+ dataUser.usingUser(managerUser).addUserToSite(contributor, managerTestSite, UserRole.SiteContributor);
+
+ testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
+ imapProtocol.authenticateUser(contributor).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
+ .then().assertThat().currentDirectoryIs(testFolder);
+
+ dataSite.usingUser(contributor).usingSite(managerTestSite).setIMAPFavorite();
+
+ FolderModel testFolder1 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
+ .usingResource(testFolder).createFolder();
+ FolderModel testFolder2 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
+ .usingResource(testFolder).createFolder();
+
+ imapProtocol.authenticateUser(contributor).usingSite(managerTestSite)
+ .usingResource(testFolder)
+ .then().assertThat().contains(testFolder1,testFolder2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify in IMAP client current directory/list of directories for CONSUMER user - folder created by other user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void consumerShouldGetCurrentWorkingDirectory() throws Exception
+ {
+ UserModel consumer = dataUser.createRandomTestUser();
+ dataUser.usingUser(managerUser).addUserToSite(consumer, managerTestSite, UserRole.SiteConsumer);
+
+ testFolder = dataContent.usingUser(managerUser).usingSite(managerTestSite).createFolder();
+ imapProtocol.authenticateUser(consumer).usingSite(managerTestSite).usingResource(testFolder).assertThat().existsInRepo()
+ .then().assertThat().currentDirectoryIs(testFolder);
+
+ dataSite.usingUser(consumer).usingSite(managerTestSite).setIMAPFavorite();
+
+ FolderModel testFolder1 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
+ .usingResource(testFolder).createFolder();
+ FolderModel testFolder2 = dataContent.usingUser(managerUser).usingSite(managerTestSite)
+ .usingResource(testFolder).createFolder();
+
+ imapProtocol.authenticateUser(consumer).usingSite(managerTestSite)
+ .usingResource(testFolder)
+ .then().assertThat().contains(testFolder1,testFolder2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify unauthorized is not able to access document library section ( PUBLIC imap SITE)")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void unAuthorizedUserCannotAccessPublicImapSiteDocumentLibrary() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ UserModel unauthorizedUser = dataUser.createRandomTestUser();
+ SiteModel publicImapSite = dataSite.usingUser(testUser).createPublicRandomSite();
+ dataSite.usingUser(unauthorizedUser).usingSite(publicImapSite).setIMAPFavorite();
+
+ imapProtocol.authenticateUser(unauthorizedUser).usingSite(publicImapSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify unauthorized is not able to access document library section ( Moderated imap SITE)")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void unAuthorizedUserCannotAccessModeratedImapSiteDocumentLibrary() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ UserModel unauthorizedUser = dataUser.createRandomTestUser();
+ SiteModel moderatedImapSite = dataSite.usingUser(testUser).createModeratedRandomSite();
+ dataSite.usingUser(unauthorizedUser).usingSite(moderatedImapSite).setIMAPFavorite();
+
+ imapProtocol.authenticateUser(unauthorizedUser).usingSite(moderatedImapSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify unauthorized is not able to access document library section ( Private imap SITE)")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = MessagingException.class,
+ expectedExceptionsMessageRegExp = ".*Access Denied.*You do not have the appropriate permissions to perform this operation.*")
+ public void unAuthorizedUserCannotAccessPrivateImapSiteDocumentLibrary() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ UserModel unauthorizedUser = dataUser.createRandomTestUser();
+ SiteModel privateImapSite = dataSite.usingUser(testUser).createPrivateRandomSite();
+ dataSite.usingUser(unauthorizedUser).usingSite(privateImapSite).setIMAPFavorite();
+
+ imapProtocol.authenticateUser(unauthorizedUser).usingSite(privateImapSite).assertThat().doesNotContain(testFolder);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapConnectionTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapConnectionTests.java
new file mode 100644
index 0000000000..db73d0a9fc
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapConnectionTests.java
@@ -0,0 +1,79 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.exception.TestConfigurationException;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for Connection to Imap
+ *
+ * @author Cristina Axinte
+ *
+ */
+public class ImapConnectionTests extends EmailTest
+{
+ @BeforeClass(alwaysRun=true)
+ public void dataPreparation() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify user can connect successfully to IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void correctUserConnectsToIMAPSuccessfully() throws Exception
+ {
+ imapProtocol.authenticateUser(testUser).then().assertThat().userIsConnected();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify user fails to connect to IMAP on different port")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY }, expectedExceptions = TestConfigurationException.class)
+ public void userFailsConnectToIMAPOnDifferentPort() throws Exception
+ {
+ imapProtocol.authenticateUser(testUser, 43).then().assertThat().userIsNotConnected();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify user can disconnect successfully from IMAP Server")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void userDisconnectsFromImapServerSuccessfully() throws Exception
+ {
+ imapProtocol.authenticateUser(testUser)
+ .disconnect().then().assertThat().userIsNotConnected();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user fails to connect to IMAP on different host")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = TestConfigurationException.class)
+ public void userFailsConnectToIMAPOnDifferentHost() throws Exception
+ {
+ imapProtocol.authenticateUser(testUser, "172.29.101.1256").then().assertThat().userIsNotConnected();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify existing user with wrong password fails to connect to IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = TestConfigurationException.class,
+ expectedExceptionsMessageRegExp =".*You missed some configuration settings in your tests: User failed to connect to IMAP server LOGIN failed. Invalid login/password$" )
+ public void userFailsConnectToIMAPWithWrongPassword() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testUser.setPassword("invalid");
+ imapProtocol.authenticateUser(testUser);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify a non existing user fails to connect to IMAP.")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = TestConfigurationException.class,
+ expectedExceptionsMessageRegExp =".*You missed some configuration settings in your tests: User failed to connect to IMAP server LOGIN failed. Invalid login/password")
+ public void nonExistentUserFailsConnectToIMAP() throws Exception
+ {
+ imapProtocol.authenticateUser(new UserModel("nonExistingUser", "pass"));
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCopyFolderTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCopyFolderTests.java
new file mode 100644
index 0000000000..d6929edab0
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCopyFolderTests.java
@@ -0,0 +1,124 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.model.*;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.FolderNotFoundException;
+import javax.mail.MessagingException;
+
+public class ImapCopyFolderTests extends EmailTest
+{
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ testUser = dataUser.createRandomTestUser();
+ adminSite = dataSite.usingAdmin().createIMAPSite();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify copy non-empty folder to a different location by admin user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldCopyNonEmptyFolder() throws Exception
+ {
+ testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ FolderModel copyFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ FolderModel copiedFolder = testFolder;
+ copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
+ dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder)
+ .copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().countMessagesIs(1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify copy folder with Manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldCopyFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel copyFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel copiedFolder = testFolder;
+ copiedFolder.setCmisLocation(Utility.buildPath(copyFolder.getCmisLocation(), testFolder.getName()));
+ copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().existsInRepo().assertThat().existsInImap();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify copy folder that has been deleted with Manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ public void siteManagerShouldNotCopyFolderThatHasBeenDeleted() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel folderModel = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder).createFolder();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(folderModel).delete()
+ .and().assertThat().doesNotExistInRepo().assertThat().doesNotContain(folderModel)
+ .then().copyTo(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify copy folder with Contributor user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void contributorShouldCopyFolder() throws Exception
+ {
+ UserModel contributorUser = dataUser.createRandomTestUser();
+ dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel copyFolder = dataContent.usingUser(contributorUser).usingSite(testSite).createFolder();
+ FolderModel copiedFolder = testFolder;
+ copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
+ dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(contributorUser).usingSite(testSite).usingResource(testFolder)
+ .copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().countMessagesIs(1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify copy folder with Collaborator user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void collaboratorShouldCopyFolder() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.createRandomTestUser();
+ dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel copyFolder = dataContent.usingUser(collaboratorUser).usingSite(testSite).createFolder();
+ FolderModel copiedFolder = testFolder;
+ copiedFolder.setProtocolLocation(Utility.buildPath(copyFolder.getProtocolLocation(), testFolder.getName()));
+ dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).usingResource(testFolder)
+ .copyTo(copyFolder).then().usingResource(copiedFolder).assertThat().countMessagesIs(1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that copy folder with Consumer user is not possible")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ public void consumerShouldNotCopyFolder() throws Exception
+ {
+ UserModel consumerUser = dataUser.createRandomTestUser();
+ dataUser.addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel copyFolder = new FolderModel("copyFolder");
+ imapProtocol.authenticateUser(consumerUser).usingSite(testSite).createFolder(copyFolder).usingResource(testFolder)
+ .copyTo(copyFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify copy folder to a location for which the user does not have permission")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class)
+ public void userCopyFolderToALocationThatHeDoesNotHaveAccess() throws Exception
+ {
+ SiteModel siteModel = dataSite.usingAdmin().createPrivateRandomSite();
+ testFolder = dataContent.usingAdmin().usingSite(testSite).createFolder();
+ FolderModel copyFolder = dataContent.usingAdmin().usingSite(siteModel).createFolder();
+ dataContent.usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingResource(testFolder)
+ .copyTo(copyFolder);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCopyMessagesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCopyMessagesTests.java
new file mode 100644
index 0000000000..5e0d5bb701
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCopyMessagesTests.java
@@ -0,0 +1,111 @@
+package org.alfresco.email.imap;
+
+import javax.mail.MessagingException;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+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.testng.SkipException;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ImapCopyMessagesTests extends EmailTest
+{
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager can copy non-empty file via IMAP client to a different location")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldCopyNonEmptyFile() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FileModel fileModel = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().copyMessageTo(testFolder).assertThat().containsMessages(fileModel);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager can copy non-empty files via IMAP client to a different location")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldCopyNonEmptyFiles() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FileModel fileModel1 = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ FileModel fileModel2 = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel1).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().usingSite(testSite).copyMessagesTo(testFolder).assertThat().containsMessages(fileModel1, fileModel2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify site manager can copy empty file via IMAP client to a different location")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerShouldCopyEmptyFile() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FileModel fileModel = new FileModel("EmptyFile.txt", FileType.TEXT_PLAIN, "");
+ fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(fileModel);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().copyMessageTo(testFolder).assertThat().containsMessages(fileModel);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can copy file via IMAP client to a location where the message already exists")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void userShouldCopyFileWhereAlreadyExists() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FileModel fileModel = new FileModel("CopyFile.txt", FileType.TEXT_PLAIN, "content of copied file");
+ dataContent.usingSite(testSite).usingResource(testFolder).createContent(fileModel);
+ FileModel fileToBeCopied = dataContent.usingSite(testSite).createContent(fileModel);
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileToBeCopied).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().copyMessageTo(testFolder).assertThat().containsMessages(fileToBeCopied);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user cannot copy a file via IMAP client if it was already deleted from repository")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
+ expectedExceptionsMessageRegExp ="There are no messages to be copied")
+ public void userCannotCopyDeletedFile() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FileModel fileModel = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInImap();
+ dataContent.usingResource(fileModel).deleteContent();
+ imapProtocol.copyMessageTo(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user cannot copy file via IMAP client to a location where you don't have permissions")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
+ expectedExceptionsMessageRegExp = ".*A4 NO APPEND failed. Can't append message - Permission denied.*")
+ public void userCannotCopyFileWhereNoPermissions() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+
+ UserModel user = dataUser.createRandomTestUser();
+ SiteModel site = dataSite.usingUser(user).createIMAPSite();
+ FileModel file = dataContent.usingUser(user).usingSite(site).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ dataSite.usingUser(user).usingSite(testSite).setIMAPFavorite();
+
+ imapProtocol.authenticateUser(user).usingSite(site).usingResource(file).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().copyMessageTo(testFolder);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCreateFolderTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCreateFolderTests.java
new file mode 100644
index 0000000000..e32bc38829
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapCreateFolderTests.java
@@ -0,0 +1,217 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.FolderNotFoundException;
+
+/**
+ * Tests for Create Folder action using IMAP client
+ *
+ * @author Cristina Axinte
+ *
+ */
+public class ImapCreateFolderTests extends EmailTest
+{
+ private UserModel adminUser;
+ private SiteModel imapSite;
+
+ @BeforeClass(alwaysRun=true)
+ public void dataPreparation() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ testUser = dataUser.createRandomTestUser();
+ imapSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify admin can create a folder in Afresco IMAP root folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminCanCreateFolderInAlfrescoImapRoot() throws Exception
+ {
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(adminUser).usingAlfrescoImap().createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify user can create a folder in Afresco IMAP root folder, but it is not displayed in Alfresco Repository")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void userCanCreateFolderInAlfrescoImapRootButNotDisplayedInRepo() throws Exception
+ {
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser).usingAlfrescoImap().createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().doesNotExistInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify admin can create a folder in Sites folder and it will be displayed in Alfresco Repository/Sites")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminCanCreateFolderInSitesFolder() throws Exception
+ {
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(adminUser)
+ .usingSites().createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify manager can create a folder in IMAP Site > documentLibrary")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void managerCanCreateFolderInIMAPSite() throws Exception
+ {
+ UserModel managerUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(managerUser, imapSite, UserRole.SiteManager);
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(managerUser)
+ .usingSite(imapSite).createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify manager can create a folder with spaces in name in IMAP Site > documentLibrary")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void managerCanCreateFolderWithSpacesInIMAPSite() throws Exception
+ {
+ UserModel managerUser = dataUser.createRandomTestUser();
+ imapSite = dataSite.usingUser(managerUser).createIMAPSite();
+ FolderModel folderToCreate = new FolderModel("Folder with spaces in name");
+
+ imapProtocol.authenticateUser(managerUser)
+ .usingSite(imapSite).createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify collaborator can create a folder in IMAP Site > documentLibrary")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void collaboratorCanCreateFolderInImapSite() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser, imapSite, UserRole.SiteCollaborator);
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(collaboratorUser)
+ .usingSite(imapSite).createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify contributor can create a folder in IMAP Site > documentLibrary")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void contributorCanCreateFolderInImapSite() throws Exception
+ {
+ UserModel contributorUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, imapSite, UserRole.SiteCollaborator);
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(contributorUser)
+ .usingSite(imapSite).createFolder(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify consumer cannot create a folder in IMAP Site > documentLibrary")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void consumerCannotCreateFolderInImapSite() throws Exception
+ {
+ UserModel consumerUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(consumerUser, imapSite, UserRole.SiteConsumer);
+ dataSite.usingUser(consumerUser).usingSite(imapSite).setIMAPFavorite();
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(consumerUser).usingSite(imapSite).createFolder(folderToCreate)
+ .and()
+ .assertThat().doesNotExistInRepo()
+ .then().usingSite(imapSite)
+ .assertThat().doesNotContain(folderToCreate);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can create folder successfully with name that contains special characters")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanCreateFolderWithSpecialCharacters() throws Exception
+ {
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FolderModel folderToCreate = new FolderModel("(a)[b]!#%^");
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(folderToCreate)
+ .then()
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can create folder successfully with name that contains symbols")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanCreateFolderWithSymbols() throws Exception
+ {
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FolderModel folderToCreate = new FolderModel("a£¥€$♊♎ ♏ ♐ ♑ ♒ ♓");
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(folderToCreate)
+ .then()
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user cannot create folder with name omegaΩ_<>./?")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCannotCreateFolderWithNameThatContainsRestrictedCharacters() throws Exception
+ {
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FolderModel folderToCreate = new FolderModel("omegaΩ_<>./?");
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(folderToCreate)
+ .and()
+ .assertThat().doesNotExistInRepo()
+ .then().usingSite(testSite)
+ .assertThat().doesNotContain(folderToCreate);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify create folder using an user and check folder can be view by another user with access to the same location/site")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void verifyUserCanViewTheFolderCreatedByAnotherUser() throws Exception
+ {
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ UserModel collaboratorUser = dataUser.createRandomTestUser();
+ dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+ FolderModel folderToCreate = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).createFolder(folderToCreate).disconnect();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(folderToCreate)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify error is returned for unauthenticated user on creating folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IllegalStateException.class,
+ expectedExceptionsMessageRegExp = "Not connected")
+ public void verifyErrorIsReturnedForUnauthenticatedUserTryingToCreateFolder() throws Exception
+ {
+ imapProtocol.authenticateUser(testUser).usingSite(imapSite).disconnect().then().createFolder(FolderModel.getRandomFolderModel());
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapDeleteFolderTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapDeleteFolderTests.java
new file mode 100644
index 0000000000..9f37177931
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapDeleteFolderTests.java
@@ -0,0 +1,259 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.FolderNotFoundException;
+
+public class ImapDeleteFolderTests extends EmailTest
+{
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ testUser = dataUser.createRandomTestUser();
+ adminSite = dataSite.usingAdmin().createIMAPSite();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify admin can delete folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldDeleteFolder() throws Exception
+ {
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(adminUser).usingSite(adminSite).createFolder(testFolder)
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(adminSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify site Manager can delete a folder with a message(file)")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldDeleteNonEmptyFolder() throws Exception
+ {
+ UserModel user = dataUser.createRandomTestUser();
+ SiteModel site = dataSite.usingUser(user).createIMAPSite();
+ FolderModel folder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(user).usingSite(site).createFolder(folder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ dataContent.usingUser(user).usingSite(site).usingResource(folder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.usingSite(site).usingResource(folder).assertThat().countMessagesIs(1)
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(site).assertThat().doesNotContain(folder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can delete a empty folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerShouldDeleteFolder() throws Exception
+ {
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(testSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can delete a folder that contains collaborator user messages")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, enabled = false)//disable since it's failing intermitent
+ public void siteManagerShouldDeleteFolderWithCollaboratorMessages() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ testFile = dataContent.usingUser(collaboratorUser).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.usingSite(testSite).usingResource(testFolder)
+ .assertThat().countMessagesIs(1)
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(testSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can delete a folder that contains contributor user messages")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, enabled = false)//disable since it's failing intermitent
+ public void siteManagerShouldDeleteFolderWithContributorMessages() throws Exception
+ {
+ UserModel contributorUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ dataContent.usingUser(contributorUser).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.usingSite(testSite).usingResource(testFolder).assertThat().countMessagesIs(1)
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(testSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that an unauthorized user can not delete folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ public void unauthorizedUserShouldNotDeleteFolder() throws Exception
+ {
+ UserModel unauthorizedUser = dataUser.createRandomTestUser();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ imapProtocol.authenticateUser(unauthorizedUser).usingResource(testFolder).delete();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can delete a folder that contains consumer user messages")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void siteManagerShouldDeleteFolderWithConsumerMessages() throws Exception
+ {
+ UserModel consumerUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(consumerUser, testSite, UserRole.SiteContributor);
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo();
+ dataContent.usingUser(consumerUser).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ dataUser.usingUser(testUser).removeUserFromSite(consumerUser, testSite);
+ dataUser.usingUser(testUser).addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).assertThat().countMessagesIs(1)
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(testSite).assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user cannot delete folder that no longer exists")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void userCannotDeleteFolderThatNoLongerExists() throws Exception
+ {
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo()
+ .delete()
+ .assertThat().doesNotExistInRepo()
+ .usingSite(testSite).assertThat().doesNotContain(testFolder)
+ .usingResource(testFolder)
+ .delete();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify deleting folder that contains messages by COLLABORATOR user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void collaboratorTriesToDeleteFolderContainingMessagesByCollaborator() throws Exception
+ {
+ UserModel collaboratorUser1 = dataUser.createRandomTestUser();
+ UserModel collaboratorUser2 = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser1, testSite, UserRole.SiteCollaborator);
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser2, testSite, UserRole.SiteCollaborator);
+ testFolder = FolderModel.getRandomFolderModel();
+
+ dataSite.usingUser(collaboratorUser1).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(collaboratorUser1).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo()
+ .disconnect();
+ testFile = dataContent.usingUser(collaboratorUser1).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ dataSite.usingUser(collaboratorUser2).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(collaboratorUser2).usingSite(testSite).usingResource(testFolder)
+ .delete()
+ .assertThat().existsInRepo()
+ .usingSite(testSite).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify deleting folder that contains messages by CONTRIBUTOR user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void contributorTriesToDeleteFolderContainingMessagesByContributor() throws Exception
+ {
+ UserModel contributorUser1 = dataUser.createRandomTestUser();
+ UserModel contributorUser2 = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser1, testSite, UserRole.SiteContributor);
+ dataUser.usingUser(testUser).addUserToSite(contributorUser2, testSite, UserRole.SiteContributor);
+ testFolder = FolderModel.getRandomFolderModel();
+
+ dataSite.usingUser(contributorUser1).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(contributorUser1).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo()
+ .disconnect();
+ testFile = dataContent.usingUser(contributorUser1).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ dataSite.usingUser(contributorUser2).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(contributorUser2).usingSite(testSite).usingResource(testFolder)
+ .delete()
+ .assertThat().existsInRepo()
+ .usingSite(testSite).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify deleting folder that contains messages by CONSUMER user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void consumerTriesToDeleteFolderContainingMessagesByConsumer() throws Exception
+ {
+ UserModel consumerUser1 = dataUser.createRandomTestUser();
+ UserModel consumerUser2 = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(consumerUser1, testSite, UserRole.SiteCollaborator);
+ dataUser.usingUser(testUser).addUserToSite(consumerUser2, testSite, UserRole.SiteConsumer);
+ testFolder = FolderModel.getRandomFolderModel();
+
+ dataSite.usingUser(consumerUser1).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(consumerUser1).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo()
+ .disconnect();
+ testFile = dataContent.usingUser(consumerUser1).usingSite(testSite).usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ dataUser.usingUser(testUser).removeUserFromSite(consumerUser1, testSite);
+ dataUser.usingUser(testUser).addUserToSite(consumerUser1, testSite, UserRole.SiteConsumer);
+ dataSite.usingUser(consumerUser2).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(consumerUser2).usingSite(testSite).usingResource(testFolder)
+ .delete()
+ .assertThat().existsInRepo()
+ .usingSite(testSite).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify delete folder from a location where you don't have permission")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void userTriesToDeleteFolderFromALocationToWhichHeDoesNotHavePermissionToDelete() throws Exception
+ {
+ UserModel userModel = dataUser.createRandomTestUser();
+ SiteModel privateSite = dataSite.usingAdmin().createIMAPSite();
+ testFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(dataUser.getAdminUser()).usingSite(privateSite).createFolder(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo()
+ .disconnect();
+
+ dataSite.usingUser(userModel).usingSite(privateSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(userModel).usingSite(testSite).usingResource(testFolder).delete();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify admin cannot delete a open folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IllegalStateException.class,
+ expectedExceptionsMessageRegExp = "This operation is not allowed on an open folder")
+ public void adminTriesToDeleteOpenFolder() throws Exception
+ {
+ testFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(adminUser).usingSite(adminSite).createFolder(testFolder)
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .attemptToDeleteOpenFolder();
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapDeleteMessagesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapDeleteMessagesTests.java
new file mode 100644
index 0000000000..fe8c70f873
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapDeleteMessagesTests.java
@@ -0,0 +1,95 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.model.*;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.MessagingException;
+
+public class ImapDeleteMessagesTests extends EmailTest
+{
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ adminSite = dataSite.usingAdmin().createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify message can be deleted from IMAP client by admin")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldDeleteMessage() throws Exception
+ {
+ testFile = dataContent.usingAdmin().usingSite(adminSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(dataUser.getAdminUser()).usingSite(adminSite).assertThat().containsMessages(testFile)
+ .and().usingResource(testFile).assertThat().existsInRepo().deleteMessage()
+ .and().assertThat().doesNotContainMessages(testFile)
+ .then().usingResource(testFile).assertThat().doesNotExistInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify deleting message via IMAP client by user with MANAGER role")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldDeleteMessage() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingResource(testFile).assertThat().existsInRepo()
+ .and().usingSite(testSite).assertThat().containsMessages(testFile).deleteMessage(testFile.getName())
+ .and().assertThat().doesNotContainMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify message has been deleted via REPOSITORU by user with MANAGER role")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerVerifyMessageHasBeenDeletedFromRepository() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ dataContent.usingUser(testUser).usingResource(testFile).deleteContent();
+ imapProtocol.authenticateUser(testUser).usingResource(testFile).assertThat().doesNotExistInRepo()
+ .and().usingSite(testSite).assertThat().doesNotContainMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify deleting message via IMAP client by user with CONTRIBUTOR role")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteContributorShouldDeleteMessage() throws Exception
+ {
+ UserModel contributorUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+ testFile = dataContent.usingUser(contributorUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(contributorUser).usingResource(testFile).deleteMessage()
+ .usingResource(testFile).assertThat().doesNotExistInRepo()
+ .and().usingSite(testSite).assertThat().doesNotContainMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify deleting message via IMAP client by user with COLLABORATOR role")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteCollaboratorShouldDeleteMessage() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+ testFile = dataContent.usingUser(collaboratorUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(collaboratorUser).usingResource(testFile).deleteMessage()
+ .usingResource(testFile).assertThat().doesNotExistInRepo()
+ .and().usingSite(testSite).assertThat().doesNotContainMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify deleting message via IMAP client by user with CONSUMER role is not permitted")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
+ expectedExceptionsMessageRegExp = ".*No permission to set DELETED flag")
+ public void siteConsumerShouldNotDeleteMessage() throws Exception
+ {
+ UserModel consumerUser = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(consumerUser, testSite, UserRole.SiteConsumer);
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(consumerUser).usingResource(testFile).deleteMessage();
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMessageFlagsTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMessageFlagsTests.java
new file mode 100644
index 0000000000..1cb777664d
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMessageFlagsTests.java
@@ -0,0 +1,58 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.Test;
+
+import javax.mail.Flags;
+
+public class ImapMessageFlagsTests extends EmailTest
+{
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager can set flags action to a content(message) through IMAP Client")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldSetFlagsToAContent() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingResource(fileModel).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .and().withMessage().setAnsweredFlag().setSeenFlag().updateFlags()
+ .then().assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify site manager can set flags to a content(message) through IMAP Client")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerShouldSetFlagsToContent() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingResource(fileModel).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .and().withMessage().setFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags()
+ .then().assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify site manager can remove flags from a content(message) through IMAP Client")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerShouldRemoveFlagsFromContent() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingResource(fileModel).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .and().withMessage().setFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags()
+ .and().assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN)
+ .and().withMessage().removeFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags()
+ .then().assertThat().messageDoesNotContainFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMoveFolderTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMoveFolderTests.java
new file mode 100644
index 0000000000..0d41f149f0
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMoveFolderTests.java
@@ -0,0 +1,146 @@
+package org.alfresco.email.imap;
+
+import javax.mail.FolderNotFoundException;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ImapMoveFolderTests extends EmailTest
+{
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ testUser = dataUser.createRandomTestUser();
+ adminSite = dataSite.usingAdmin().createIMAPSite();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify move non-empty folder to a different location by admin user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldMoveNonEmptyFolder() throws Exception
+ {
+ testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ dataContent.usingAdmin().usingResource(testFolder).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder).moveTo(moveToFolder)
+ .and().usingResource(testFolder).assertThat().doesNotExistInRepo()
+ .then().usingResource(moveToFolder).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify move folder with Manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldMoveFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
+ .and().usingResource(testFolder).assertThat().doesNotExistInRepo()
+ .then().usingResource(moveToFolder).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify move folder at location where the folder already exists is successful")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void userShouldMoveFolderWhereAlreadyExists() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ dataContent.usingUser(testUser).usingSite(testSite)
+ .usingResource(moveToFolder)
+ .createFolder(testFolder);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
+ .and().usingResource(testFolder).assertThat().doesNotExistInRepo()
+ .then().usingResource(moveToFolder).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify move folder with Contributor will create the new folder, but is NOT able to delete the current one")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteContributorCannotMoveFolder() throws Exception
+ {
+ UserModel siteContributor = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(siteContributor, testSite, UserRole.SiteContributor);
+ dataSite.usingUser(siteContributor).usingSite(testSite).setIMAPFavorite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+
+ imapProtocol.authenticateUser(siteContributor).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
+ .usingResource(moveToFolder).assertThat().contains(testFolder)
+ .and().usingResource(testFolder).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify move folder with Collaborator will create the new folder, but is NOT able to delete the current one")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteCollaboratorCannotMoveFolder() throws Exception
+ {
+ UserModel siteCollaborator = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(siteCollaborator, testSite, UserRole.SiteContributor);
+ dataSite.usingUser(siteCollaborator).usingSite(testSite).setIMAPFavorite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+
+ imapProtocol.authenticateUser(siteCollaborator).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
+ .usingResource(moveToFolder).assertThat().contains(testFolder)
+ .and().usingResource(testFolder).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify move folder with Consumer will create the new folder, but is NOT able to delete the current one")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteConsumerCannotMoveFolder() throws Exception
+ {
+ UserModel siteConsumer = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(siteConsumer, testSite, UserRole.SiteContributor);
+ dataSite.usingUser(siteConsumer).usingSite(testSite).setIMAPFavorite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+
+ imapProtocol.authenticateUser(siteConsumer).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
+ .usingResource(moveToFolder).assertThat().contains(testFolder)
+ .and().usingResource(testFolder).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify move folder fails using user that doesn't have permission to the IMAP site")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ public void unauthorizedUserCannotMoveFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+
+ UserModel unauthorizedUser = dataUser.createRandomTestUser();
+ dataSite.usingUser(unauthorizedUser).usingSite(testSite).setIMAPFavorite();
+
+ imapProtocol.authenticateUser(unauthorizedUser).usingSite(testSite).usingResource(testFolder).moveTo(moveToFolder)
+ .usingResource(moveToFolder).assertThat().doesNotContain(testFolder)
+ .and().usingResource(testFolder).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify move folder with Manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void siteManagerShouldNotMoveDeletedFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FolderModel moveToFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .assertThat().existsInImap()
+ .assertThat().existsInRepo()
+ .delete()
+ .moveTo(moveToFolder);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMoveMessagesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMoveMessagesTests.java
new file mode 100644
index 0000000000..31ee6b0931
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapMoveMessagesTests.java
@@ -0,0 +1,27 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.Test;
+
+public class ImapMoveMessagesTests extends EmailTest
+{
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager can move message via IMAP client to a different location")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldMoveNonEmptyFile() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ FileModel fileModel = dataContent.usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(fileModel).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().moveMessageTo(testFolder).assertThat().containsMessages(fileModel)
+ .and().usingSite(testSite).assertThat().doesNotContainMessages(fileModel);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java
new file mode 100644
index 0000000000..9419f16216
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java
@@ -0,0 +1,180 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+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.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.Flags;
+import javax.mail.MessagingException;
+import java.io.IOException;
+
+public class ImapReadMessagesTests extends EmailTest
+{
+ @BeforeClass(alwaysRun=true)
+ public void dataPreparation() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ adminUser = dataUser.getAdminUser();
+ adminSite = dataSite.usingAdmin().createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify folders created in repository in other folder via IMAP client by admin user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldGetFoldersCreatedInRepositoryViaImap() throws Exception
+ {
+ testFolder = dataContent.usingAdmin().usingSite(testSite).createFolder();
+ FolderModel testFolder1 = FolderModel.getRandomFolderModel();
+ FolderModel testFolder2 = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder).createFolder(testFolder1)
+ .and().assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().usingResource(testFolder).createFolder(testFolder2).assertThat().existsInRepo()
+ .and().assertThat().existsInImap();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify file and its content are displayed via IMAP client when the file is created by site manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldGetFileAndItsContentsViaImap() throws Exception
+ {
+ FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(fileModel)
+ .and().usingResource(fileModel).assertThat().existsInRepo()
+ .then().assertThat().fileContentIsDisplayed();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify that file content in IMAP client contains creator, title, description, created date, " +
+ "modifier, modified date, size, three links to content folder, to content url, to download url")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldVerifyFileContent() throws Exception
+ {
+ FileModel fileModel = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(fileModel)
+ .and().usingResource(fileModel).assertThat().existsInRepo()
+ .then().assertThat().messageContentMatchesFileModelData(fileModel);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that the admin user can mark a message as read")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void adminCanMarkMessageAsRead() throws Exception
+ {
+ testFile = dataContent.usingUser(adminUser).usingSite(adminSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(adminUser).usingResource(testFile).withMessage().setSeenFlag().updateFlags()
+ .then().assertThat().messageContainsFlags(Flags.Flag.SEEN);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can see wiki pages via IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerCanViewWikiPages() throws Exception
+ {
+ dataWiki.usingUser(testUser).usingSite(testSite).createRandomWiki();
+ imapProtocol.authenticateUser(testUser).usingSiteWikiContainer(testSite).assertThat().countMessagesIs(1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that collaborator can see files created by self")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void collaboratorCanViewFileCreatedBySelf() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.createRandomTestUser();
+ dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+ testFile = dataContent.usingUser(collaboratorUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).assertThat().containsMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that contributor can see files created by self")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void contributorCanViewFileCreatedBySelf() throws Exception
+ {
+ UserModel contributorUser = dataUser.createRandomTestUser();
+ dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+ testFile = dataContent.usingUser(contributorUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(contributorUser).usingSite(testSite).assertThat().containsMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify file created with spaces in the name is displayed in IMAP client")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void fileWithSpacesInNameIsDisplayedInImap() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("name with spaces.txt", FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(testFile);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that a file created with name which contains special characters is visible in IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanViewFileWithSpecialCharactersInNameViaIMAP() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("(a)[b]!#%^.txt", FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(testUser)
+ .usingSite(testSite).assertThat().containsMessages(testFile)
+ .usingResource(testFile).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that a file created with name which contains symbols is visible in IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanViewFileWithSymbolsInNameViaIMAP() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("a£¥€$♊♎♏♐♑♒♓Ω.txt", FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(testUser)
+ .usingSite(testSite).assertThat().containsMessages(testFile)
+ .usingResource(testFile).assertThat().existsInRepo();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can see links via IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void siteManagerCanViewLinks() throws Exception
+ {
+ dataLink.usingUser(testUser).usingSite(testSite).createRandomLink();
+ imapProtocol.authenticateUser(testUser).usingSiteLinksContainer(testSite).assertThat().countMessagesIs(1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can see calendar events via IMAP")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void siteManagerCanViewCalendarEvents() throws Exception
+ {
+ dataCalendarEvent.usingUser(testUser).usingSite(testSite).createRandomCalendarEvent();
+ imapProtocol.authenticateUser(testUser).usingSiteCalendarContainer(testSite).assertThat().countMessagesIs(1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager cannot read file via IMAP if it is already deleted from repository")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = MessagingException.class,
+ expectedExceptionsMessageRegExp = "No message with subject .* has been found")
+ public void siteManagerCannotReadFileInImapIfItWasDeletedFromRepository() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite)
+ .createContent(new FileModel(RandomData.getRandomName("File"), FileType.TEXT_PLAIN));
+ dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFile).deleteContent();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().fileContentIsDisplayed();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager cannot read file via IMAP client if it is locked by an user in repository")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IOException.class,
+ expectedExceptionsMessageRegExp = "No content")
+ public void siteManagerCannotReadFileInImapIfItsLocked() throws Exception
+ {
+ String content = RandomData.getRandomAlphanumeric();
+ testFile = dataContent.usingUser(testUser).usingSite(testSite)
+ .createContent(new FileModel(RandomData.getRandomName("File"), FileType.TEXT_PLAIN, content));
+ dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFile).checkOutDocument();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().fileContentIsDisplayed();
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapRenameFolderTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapRenameFolderTests.java
new file mode 100644
index 0000000000..c7f3471c08
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapRenameFolderTests.java
@@ -0,0 +1,361 @@
+package org.alfresco.email.imap;
+
+import javax.mail.FolderNotFoundException;
+
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.data.RandomData;
+import org.alfresco.utility.exception.TestConfigurationException;
+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.commons.lang3.RandomStringUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ImapRenameFolderTests extends EmailTest
+{
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ testUser = dataUser.createRandomTestUser();
+ adminSite = dataSite.usingAdmin().createIMAPSite();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify rename folder by admin user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void adminShouldRenameFolder() throws Exception
+ {
+ testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(adminUser).usingSite(adminSite).usingResource(testFolder).rename(newFolderName)
+ .usingSite(adminSite)
+ .assertThat().contains(new FolderModel(newFolderName))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify renaming folder by user with MANAGER role")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldRenameFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).rename(newFolderName)
+ .usingSite(testSite)
+ .assertThat().contains(new FolderModel(newFolderName))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with MANAGER role is not able to rename an nonexistent folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ public void siteManagerShouldNotRenameNonExistentFolder() throws Exception
+ {
+ String newFolderName = RandomData.getRandomName("Folder");
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(FolderModel.getRandomFolderModel())
+ .rename(newFolderName)
+ .assertThat().contains(testFolder)
+ .and().assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with MANAGER role is able to rename a folder with long name")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerShouldRenameFolderWithLongName() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String longName = RandomStringUtils.randomAlphabetic(200);
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .rename(longName)
+ .usingSite(testSite)
+ .assertThat().contains(new FolderModel(longName))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify unauthorized user is not able to rename a folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void unauthorizedUserShouldNotRenameFolder() throws Exception
+ {
+ UserModel unauthorizedUser = dataUser.createRandomTestUser();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+
+ dataSite.usingUser(unauthorizedUser).usingSite(testSite).setIMAPFavorite();
+
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(unauthorizedUser).usingResource(testFolder)
+ .rename(newFolderName)
+ .then().assertThat().doesNotExistInRepo()
+ .assertThat().contains(testFolder)
+ .and().assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify inexistent user is not able to rename a folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = TestConfigurationException.class,
+ expectedExceptionsMessageRegExp = ".*You missed some configuration settings in your tests: User failed to connect to IMAP server LOGIN failed. Invalid login/password$")
+ public void nonexistentUserShouldNotRenameFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+
+ imapProtocol.authenticateUser(UserModel.getRandomUserModel()).usingResource(testFolder)
+ .rename(newFolderName)
+ .then().assertThat().doesNotExistInRepo()
+ .and().assertThat().contains(testFolder)
+ .and().assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify disconnected user is not able to rename a folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = IllegalStateException.class,
+ expectedExceptionsMessageRegExp= "Not connected")
+ public void disconnectedUserShouldNotRenameFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+
+ imapProtocol.authenticateUser(testUser).usingResource(testFolder).assertThat().existsInImap().then()
+ .disconnect().usingResource(testFolder)
+ .rename(newFolderName)
+ .then().assertThat().doesNotExistInRepo()
+ .and().assertThat().contains(testFolder)
+ .and().assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify renaming folder by user with COLLABORATOR role - folder created by self")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void collaboratorShouldRenameFolderCreatedBySelf() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+
+ dataSite.usingUser(collaboratorUser).usingSite(testSite).setIMAPFavorite();
+
+ testFolder = dataContent.usingUser(collaboratorUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).usingResource(testFolder)
+ .rename(newFolderName)
+ .usingSite(testSite)
+ .assertThat().contains(new FolderModel(newFolderName))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with COLLABORATOR role is not able to rename a folder created by other user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void collaboratorShouldNotRenameFolderCreatedByOtherUser() throws Exception
+ {
+ UserModel collaboratorUser = dataUser.usingAdmin().createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator);
+
+ dataSite.usingUser(collaboratorUser).usingSite(testSite).setIMAPFavorite();
+
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(collaboratorUser).usingResource(testFolder).rename(newFolderName)
+ .usingSite(testSite)
+ .assertThat().contains(testFolder)
+ .assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with CONTRIBUTOR role is able to rename a folder created by self")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void contributorShouldRenameFolderCreatedBySelf() throws Exception
+ {
+ UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+
+ dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
+
+ testFolder = dataContent.usingUser(contributorUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(contributorUser).usingSite(testSite).usingResource(testFolder)
+ .rename(newFolderName)
+ .usingSite(testSite)
+ .assertThat().contains(new FolderModel(newFolderName))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with CONTRIBUTOR role is NOT able to rename a folder created by other user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void contributorShouldNotRenameFolderCreatedByOtherUser() throws Exception
+ {
+ UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+
+ dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
+
+ FolderModel testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(contributorUser).usingSite(testSite).usingResource(testFolder)
+ .rename(newFolderName).usingSite(testSite).then().assertThat().contains(testFolder)
+ .and().assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with CONSUMER role is not able to rename a folder created by other user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void consumerShouldNotRenameFolderCreatedByOtherUser() throws Exception
+ {
+ UserModel consumer = dataUser.createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(consumer, testSite, UserRole.SiteConsumer);
+
+ dataSite.usingUser(consumer).usingSite(testSite).setIMAPFavorite();
+
+ FolderModel testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String newFolderName = RandomData.getRandomName("Folder");
+ imapProtocol.authenticateUser(consumer).usingSite(testSite).usingResource(testFolder)
+ .rename(newFolderName).usingSite(testSite).then()
+ .assertThat().contains(testFolder)
+ .and().assertThat().doesNotContain(new FolderModel(newFolderName));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify renaming folder fails when it was deleted by another user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void userCannotRenameFolderDeletedByAnotherUser() throws Exception
+ {
+ UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(contributorUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .delete().disconnect();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).rename("deletedFolderRename");
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can rename folder to a name that contains white spaces")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanRenameFolderToAFolderThatContainsWhiteSpaces() throws Exception
+ {
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .and()
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .rename("folder with name that contains spaces")
+ .then().usingSite(testSite)
+ .assertThat().contains(new FolderModel("folder with name that contains spaces"))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can rename folder successfully with name that contains special characters")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanRenameFolderWithSpecialCharacters() throws Exception
+ {
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .and()
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .rename("(a)[b]!#%^")
+ .then().usingSite(testSite)
+ .assertThat().contains(new FolderModel("(a)[b]!#%^"))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can rename folder successfully with name that contains symbols")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCanRenameFolderWithSymbols() throws Exception
+ {
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .and()
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .rename("a£¥€$♊♎ ♏ ♐ ♑ ♒ ♓")
+ .then().usingSite(testSite)
+ .assertThat().contains(new FolderModel("a£¥€$♊♎ ♏ ♐ ♑ ♒ ♓"))
+ .assertThat().doesNotContain(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user cannot create folder with name omegaΩ_<>./?")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void userCannotRenameFolderWithNameThatContainsRestrictedCharacters() throws Exception
+ {
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .and()
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .rename("omegaΩ_<>./?")
+ .then().usingSite(testSite)
+ .assertThat().contains(testFolder)
+ .assertThat().doesNotContain(new FolderModel("omegaΩ_<>./?"));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify renaming folder fails when it was renamed by another user")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void userCannotRenameFolderRenamedByAnotherUser() throws Exception
+ {
+ UserModel contributorUser = dataUser.usingAdmin().createRandomTestUser();
+ dataUser.usingUser(testUser).addUserToSite(contributorUser, testSite, UserRole.SiteContributor);
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ dataSite.usingUser(contributorUser).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(contributorUser).usingSite(testSite).createFolder(testFolder)
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .rename("folderRenamedByUser").disconnect();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder).rename("deletedFolderRename");
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify a site folder cannot be renamed via IMAP client")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void verifyASiteFolderCannotBeRenamedViaImap() throws Exception
+ {
+ SiteModel siteModel = dataSite.usingUser(testUser).createIMAPSite();
+
+ imapProtocol.authenticateUser(testUser).usingSiteRoot(siteModel).rename("new site name")
+ .and()
+ .assertThat().doesNotExistInRepo()
+ .then().usingSites()
+ .assertThat().doesNotContain(new FolderModel("new site name"));
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify renaming folder by changing the case")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL })
+ public void verifyFolderCanBeRenamedByChangingTheCase() throws Exception
+ {
+ FolderModel testFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).createFolder(testFolder)
+ .and()
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .rename(testFolder.getName().toUpperCase())
+ .then().usingSite(testSite)
+ .assertThat().contains(new FolderModel(testFolder.getName().toUpperCase()))
+ .assertThat().doesNotContain(testFolder);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapRenameMessagesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapRenameMessagesTests.java
new file mode 100644
index 0000000000..55e3384f1f
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapRenameMessagesTests.java
@@ -0,0 +1,34 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.FileType;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class ImapRenameMessagesTests extends EmailTest
+{
+ @BeforeClass(alwaysRun=true)
+ public void dataPreparation() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify the renamed file from repository is still preset in IMAP client with the old name for site manager")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void siteManagerShouldVerifyFileContentForRenamedFileViaImap() throws Exception
+ {
+ testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(CMISUtil.DocumentType.TEXT_PLAIN);
+ FileModel renamedFile = testFile;
+ renamedFile.setName(FileModel.getRandomFileModel(FileType.TEXT_PLAIN).getName());
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().existsInRepo()
+ .and().assertThat().existsInImap()
+ .then().renameMessageTo(renamedFile).assertThat().messageContentMatchesFileModelData(testFile);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapSearchMessagesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapSearchMessagesTests.java
new file mode 100644
index 0000000000..dd74390949
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapSearchMessagesTests.java
@@ -0,0 +1,118 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.model.FileModel;
+import org.alfresco.utility.model.FileType;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.Test;
+
+/**
+ * Tests for Search for Messages in IMAP client
+ *
+ * @author Cristina Axinte
+ *
+ */
+public class ImapSearchMessagesTests extends EmailTest
+{
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify that no results are returned when searching for a message name term with no match")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void noResultsReturnedWhenSearchingForNotExistingMessage() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String fileName1="File-new1";
+ FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
+ String fileName2="File2";
+ FileModel fileModel2 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .searchSubjectFor("new").assertThat().resultsContainMessage(fileModel1)
+ .assertThat().resultsDoNotContainMessage(fileModel2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.SANITY,
+ description = "Verify that searched message is returned when searching for full message name")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.SANITY })
+ public void searchedMessageIsReturnedWhenSearchingForFullMessageName() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ String fileName1="File-new1";
+ FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
+ String fileName2="File2";
+ FileModel fileModel2 = dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFolder)
+ .searchSubjectFor("File2").assertThat().resultsContainMessage(fileModel2)
+ .assertThat().resultsDoNotContainMessage(fileModel1);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that search results are returned for search term containing white spaces")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerVerifySearchResultsForWhiteSpaces() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ String fileName1="File new";
+ FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite)
+ .createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
+ String fileName2="File new1";
+ FileModel fileModel2 = dataContent.usingSite(testSite)
+ .createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).searchSubjectFor("File new")
+ .assertThat().resultsContainMessage(fileModel1, fileModel2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that search results are returned for search term containing wildcards")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerVerifySearchResultsForWildcards() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ String fileName1="File new 1";
+ FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite)
+ .createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
+ String fileName2="File presentation 2";
+ FileModel fileModel2 = dataContent.usingSite(testSite)
+ .createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).searchSubjectWithWildcardsFor("File.*1.*")
+ .assertThat().resultsContainMessage(fileModel1)
+ .assertThat().resultsDoNotContainMessage(fileModel2);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that search results are returned for search term containing special characters")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerVerifySearchResultsForSpecialCharacters() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ String fileName1="File@#$%^&()-_=+-[]{};'";
+ FileModel fileModel1 = dataContent.usingUser(testUser).usingSite(testSite)
+ .createContent(new FileModel(fileName1, fileName1, fileName1 + "description", FileType.TEXT_PLAIN, fileName1 + "content"));
+ String fileName2="File";
+ FileModel fileModel2 = dataContent.usingSite(testSite)
+ .createContent(new FileModel(fileName2, fileName2, fileName2 + "description", FileType.TEXT_PLAIN, fileName2 + "content"));
+
+ imapProtocol.authenticateUser(testUser).usingSite(testSite)
+ .searchSubjectFor("=").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
+ .searchSubjectFor("@").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
+ .searchSubjectFor("#").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
+ .searchSubjectFor("$").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
+ .searchSubjectFor("@#").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2)
+ .searchSubjectFor("[]").assertThat().resultsContainMessage(fileModel1).assertThat().resultsDoNotContainMessage(fileModel2);
+ }
+}
diff --git a/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapSitesTests.java b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapSitesTests.java
new file mode 100644
index 0000000000..6522185eab
--- /dev/null
+++ b/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapSitesTests.java
@@ -0,0 +1,81 @@
+package org.alfresco.email.imap;
+
+import org.alfresco.email.EmailTest;
+import org.alfresco.utility.model.FolderModel;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.mail.FolderNotFoundException;
+import javax.mail.MessagingException;
+
+public class ImapSitesTests extends EmailTest
+{
+ @BeforeClass(alwaysRun=true)
+ public void dataPreparation() throws Exception
+ {
+ testUser = dataUser.createRandomTestUser();
+ testSite = dataSite.usingUser(testUser).createIMAPSite();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager can unsubscribe from a folder")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerCanUnSubscribeFromAFolder() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().isSubscribed()
+ .usingResource(testFolder).assertThat().isSubscribed()
+ .unsubscribe().assertThat().isNotSubscribed()
+ .usingSite(testSite).assertThat().isSubscribed();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that site manager is subscribed to folders created by self")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE })
+ public void siteManagerIsSubscribedToFoldersCreatedBySelf() throws Exception
+ {
+ testFolder = new FolderModel("newFolder");
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().isSubscribed()
+ .createFolder(testFolder).assertThat().existsInRepo().assertThat().existsInImap()
+ .assertThat().isSubscribed();
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that operations on a private site are not permitted")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = MessagingException.class,
+ expectedExceptionsMessageRegExp = ".* Access Denied.*You do not have the appropriate permissions to perform this operation.*")
+ public void verifyOperationsOnPrivateSiteAreNotPermitted() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ adminSite = dataSite.usingAdmin().createPrivateRandomSite();
+ testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ dataSite.usingUser(testUser).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(testUser).usingSite(adminSite).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that operations on a moderated site are not permitted")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ public void verifyOperationsOnModeratedSiteAreNotPermitted() throws Exception
+ {
+ adminUser = dataUser.getAdminUser();
+ adminSite = dataSite.usingAdmin().createModeratedRandomSite();
+ testFolder = dataContent.usingAdmin().usingSite(adminSite).createFolder();
+ dataSite.usingUser(testUser).usingSite(testSite).setIMAPFavorite();
+ imapProtocol.authenticateUser(testUser).usingSite(adminSite).assertThat().contains(testFolder);
+ }
+
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION,
+ description = "Verify site cannot be accessed in IMAP client if it is no longer an IMAP site or marked as IMAP favorite")
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = FolderNotFoundException.class)
+ public void userCannotAccessSiteThatIsNoLongerAnImapSiteOrMarkedAsImapFavorite() throws Exception
+ {
+ testFolder = dataContent.usingUser(testUser).usingSite(testSite).createFolder();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().contains(testFolder);
+ dataSite.usingUser(testUser).usingSite(testSite).unsetIMAPFavorite();
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().contains(testFolder);
+ }
+}
diff --git a/tests/tas-email/src/test/resources/alfresco-email-context.xml b/tests/tas-email/src/test/resources/alfresco-email-context.xml
new file mode 100644
index 0000000000..d6a5817e9c
--- /dev/null
+++ b/tests/tas-email/src/test/resources/alfresco-email-context.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-email/src/test/resources/default.properties b/tests/tas-email/src/test/resources/default.properties
new file mode 100644
index 0000000000..6dd13d4b3d
--- /dev/null
+++ b/tests/tas-email/src/test/resources/default.properties
@@ -0,0 +1,97 @@
+# dataprep related
+alfresco.scheme=http
+alfresco.server=localhost
+alfresco.port=8082
+
+# credentials
+admin.user=admin
+admin.password=admin
+
+# 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
+
+# IMAP Service settings from admin console
+imap.server=${alfresco.server}
+imap.port=143
+imaps.port=993
+
+# Inbound Email settings from admin console
+smtp.server=${alfresco.server}
+smtp.port=25
+smtp.authentication.enabled=true
+smtp.tsl.enabled=false
+
+# Outbound Email settings from admin console
+mail.encoding=UTF-8
+mail.from.default=alfresco.cloud@gmail.com
+mail.from.enabled=true
+mail.host=smtp.gmail.com
+mail.password=eiWei6vieiWei6vieiWei6vieiWei6vi
+mail.port=465
+mail.protocol=smtps
+mail.smtp.auth=true
+mail.smtp.debug=false
+mail.smtp.starttls.enable=true
+mail.smtp.timeout=30000
+mail.smtps.auth=true
+mail.smtps.starttls.enable=true
+mail.username=alfresco.cloud@gmail.com
+
+# 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=
+# testManagement.apiKey=
+# testManagement.project=
+# 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://:3306/alfresco
+#
+# Oracle:
+# db.url = jdbc:oracle://:3306/alfresco
+#
+# MariaDB:
+# db.url = jdbc:mariadb://:3306/alfresco
+#
+db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
+db.username = alfresco
+db.password = alfresco
diff --git a/tests/tas-email/src/test/resources/email-suite.xml b/tests/tas-email/src/test/resources/email-suite.xml
new file mode 100644
index 0000000000..ecb87f6d2d
--- /dev/null
+++ b/tests/tas-email/src/test/resources/email-suite.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/tas-email/src/test/resources/log4j.properties b/tests/tas-email/src/test/resources/log4j.properties
new file mode 100644
index 0000000000..00e9b5a114
--- /dev/null
+++ b/tests/tas-email/src/test/resources/log4j.properties
@@ -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
\ No newline at end of file
diff --git a/tests/tas-email/src/test/resources/shared-resources/email-runner-suite.xml b/tests/tas-email/src/test/resources/shared-resources/email-runner-suite.xml
new file mode 100644
index 0000000000..0ff426e2c8
--- /dev/null
+++ b/tests/tas-email/src/test/resources/shared-resources/email-runner-suite.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/tas-email/src/test/resources/shared-resources/email-sanity-suite.xml b/tests/tas-email/src/test/resources/shared-resources/email-sanity-suite.xml
new file mode 100644
index 0000000000..d8831e3131
--- /dev/null
+++ b/tests/tas-email/src/test/resources/shared-resources/email-sanity-suite.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-email/src/test/resources/shared-resources/email-suites.xml b/tests/tas-email/src/test/resources/shared-resources/email-suites.xml
new file mode 100644
index 0000000000..0afc400acc
--- /dev/null
+++ b/tests/tas-email/src/test/resources/shared-resources/email-suites.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tests/tas-email/src/test/resources/shared-resources/tas-email-sanity-suite.xml b/tests/tas-email/src/test/resources/shared-resources/tas-email-sanity-suite.xml
new file mode 100644
index 0000000000..e900cfb97d
--- /dev/null
+++ b/tests/tas-email/src/test/resources/shared-resources/tas-email-sanity-suite.xml
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-email/src/test/resources/shared-resources/testCount.xml b/tests/tas-email/src/test/resources/shared-resources/testCount.xml
new file mode 100644
index 0000000000..2e0aaaac54
--- /dev/null
+++ b/tests/tas-email/src/test/resources/shared-resources/testCount.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-email/src/test/resources/shared-resources/testdata/imap-input-data.xml b/tests/tas-email/src/test/resources/shared-resources/testdata/imap-input-data.xml
new file mode 100644
index 0000000000..53bf3f4955
--- /dev/null
+++ b/tests/tas-email/src/test/resources/shared-resources/testdata/imap-input-data.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ /Sites/site1/documentLibrary
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/tas-email/src/test/resources/shared-resources/testdata/imap-resource b/tests/tas-email/src/test/resources/shared-resources/testdata/imap-resource
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/tas-integration/pom.xml b/tests/tas-integration/pom.xml
new file mode 100644
index 0000000000..0fdb7773b2
--- /dev/null
+++ b/tests/tas-integration/pom.xml
@@ -0,0 +1,134 @@
+
+
+ 4.0.0
+ org.alfresco.tas
+ content-repository-community-integration-test
+ content-repository-community-integration-test
+ 6.3.0-SNAPSHOT
+ jar
+
+
+ org.alfresco
+ content-repository-community-tas-tests-parent
+ 6.3.0-SNAPSHOT
+ ../pom.xml
+
+
+
+
+ Paul Brodner
+
+ Test Automation Architect
+
+
+
+
+
+ ${project.basedir}/src/test/resources/integration-suite.xml
+ 2.5.5
+ 1.5.1
+
+
+
+
+ org.alfresco.tas
+ utility
+ test
+
+
+
+ io.rest-assured
+ rest-assured
+ test
+
+
+
+ javax.mail
+ javax.mail-api
+ ${dependency.javax.mail.version}
+ test
+
+
+
+ com.sun.mail
+ javax.mail
+ ${dependency.javax.mail.version}
+
+
+
+ org.codehaus.groovy
+ groovy
+ ${dependency.groovy.version}
+
+
+
+
+ org.alfresco.tas
+ ftp
+ test
+
+
+
+
+ org.alfresco.tas
+ restapi
+ test
+
+
+
+
+ org.alfresco.tas
+ cmis
+ test
+
+
+
+
+ org.alfresco.tas
+ email
+ test
+
+
+
+
+ org.alfresco.tas
+ webdav
+ test
+
+
+
+ com.jayway.jsonpath
+ json-path
+ 2.3.0
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ ${suiteXmlFile}
+
+
+ --illegal-access=warn
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ test-jar
+
+
+
+
+
+
+
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java
new file mode 100644
index 0000000000..7f211292c1
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java
@@ -0,0 +1,1494 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import javax.mail.FolderNotFoundException;
+
+import org.alfresco.rest.model.RestCommentModel;
+import org.alfresco.rest.model.RestDeploymentModel;
+import org.alfresco.rest.model.RestDeploymentModelsCollection;
+import org.alfresco.rest.model.RestErrorModel;
+import org.alfresco.rest.model.RestPersonFavoritesModel;
+import org.alfresco.rest.model.RestPersonFavoritesModelsCollection;
+import org.alfresco.rest.model.RestRatingModel;
+import org.alfresco.utility.Utility;
+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.CmisPermissionDeniedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
+import org.apache.commons.lang3.RandomStringUtils;
+import org.springframework.http.HttpStatus;
+import org.testng.annotations.Test;
+
+import junit.framework.Assert;
+
+/**
+ * Created by Claudia Agache on 12/13/2016.
+ */
+public class IntegrationCoreTests extends IntegrationTest
+{
+ UserModel testUser1, testUser2;
+ SiteModel testSitePublic, testSiteModerated, testSitePrivate, secondPublicSite;
+ FolderModel testFolder1, testFolder2, parentFolder1;
+ private String renamePrefix = "edited-";
+ FileModel testFile1, testFile2, childDoc1, childDoc2, childDoc3, childDoc4, childDoc5;
+ RestRatingModel returnedRatingModel;
+ RestPersonFavoritesModel restPersonFavoritesModel;
+ private String newContent = "new TAS content";
+
+ /**
+ * Scenario 22
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a public test site and U2 a public test site using CMIS
+ * 3. U1 creates a folder with a file in his public site's document library using WebDav
+ * 4. U1 tries to move his folder to U2 public site using IMAP
+ * 5. Verify folder with file is not moved. U1 is not authorized to access the public site
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class)
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is not able to move a folder with a file to a public site if he is not a member of that site.")
+ public void moveFolderWithFileToPublicSiteByUninvitedUser() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site and U2 a public test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ secondPublicSite = dataSite.usingUser(testUser2).createIMAPSite();
+
+ STEP("3. U1 creates a folder with a file in public site's document library using WebDav");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFolder(testFolder1).assertThat().existsInWebdav()
+ .usingResource(testFolder1).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 tries to move his folder to U2 public site using IMAP. 5. Verify folder with file is not moved. U1 is not authorized to access the U2 public site");
+ FolderModel destination = new FolderModel(Utility.buildPath("Sites", secondPublicSite.getId(), "documentLibrary"));
+ destination.setProtocolLocation(imapProtocol.authenticateUser(testUser2).usingSite(secondPublicSite).getLastResourceWithoutPrefix());
+ imapProtocol.authenticateUser(testUser1)
+ .usingResource(testFolder1).moveTo(destination)
+ .assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 23
+ * 1. Using CMIS create 1 test user: u1
+ * 2. U1 creates a public test site
+ * 3. U1 creates a folder (parentFolder) inside public site's document library using WebDav
+ * 4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP
+ * 5. Inside parentFolder create 1 subfolder using IMAP
+ * 6. Delete parentFolder using CMIS
+ * 7. Verify folder is deleted along with all its children
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is able to delete parent folder along with all its children using CMIS.")
+ public void deleteFolderWithChildrenUsingCMIS() throws Exception
+ {
+ STEP("1. Using CMIS create 1 test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createIMAPSite();
+
+ STEP("3. U1 creates a folder (parentFolder) inside public site's document library using WebDav");
+ FolderModel parentFolder = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1)
+ .usingSite(testSitePublic).createFolder(parentFolder)
+ .assertThat().existsInWebdav()
+ .and().assertThat().existsInRepo();
+
+ STEP("4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD);
+ FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML);
+ FileModel testFile4 = FileModel.getRandomFileModel(FileType.EXE);
+ cmisAPI.authenticateUser(testUser1).usingResource(parentFolder)
+ .createFile(testFile1).assertThat().existsInRepo();
+ webDavProtocol.usingResource(parentFolder).createFile(testFile2)
+ .assertThat().existsInWebdav().and()
+ .assertThat().existsInRepo();
+ cmisAPI.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile3)
+ .assertThat().existsInRepo();
+ ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile4)
+ .assertThat().existsInFtp().and()
+ .assertThat().existsInRepo();
+
+ STEP("5. Inside parentFolder create 1 subfolder using IMAP");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser1)
+ .usingResource(parentFolder).createFolder(testFolder1)
+ .assertThat().existsInImap().and()
+ .assertThat().existsInRepo();
+
+ STEP("6. Delete parentFolder using CMIS 7. Verify folder is deleted along with all its children");
+ cmisAPI.usingResource(parentFolder).deleteFolderTree().and().assertThat().doesNotExistInRepo()
+ .usingResource(testFolder1).assertThat().doesNotExistInRepo()
+ .usingResource(testFile1).assertThat().doesNotExistInRepo()
+ .usingResource(testFile2).assertThat().doesNotExistInRepo()
+ .usingResource(testFile3).assertThat().doesNotExistInRepo()
+ .usingResource(testFile4).assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 24
+ * 1. Using CMIS create 1 test user: u1
+ * 2. U1 creates a public test site
+ * 3. U1 creates a folder (parentFolder) inside public site's document library using IMAP
+ * 4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP
+ * 5. Inside parentFolder create 1 subfolder using WebDAV
+ * 6. Delete parentFolder using WebDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is able to delete parent folder along with all its children using WebDAV.")
+ public void deleteFolderWithChildrenUsingWebDAV() throws Exception
+ {
+ STEP("1. Using CMIS create 1 test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createIMAPSite();
+
+ STEP("3. U1 creates a folder (parentFolder) inside public site's document library using IMAP");
+ FolderModel parentFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser1)
+ .usingSite(testSitePublic).createFolder(parentFolder)
+ .assertThat().existsInImap().and()
+ .assertThat().existsInRepo();
+
+ STEP("4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD);
+ FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML);
+ FileModel testFile4 = FileModel.getRandomFileModel(FileType.EXE);
+ cmisAPI.authenticateUser(testUser1).usingResource(parentFolder)
+ .createFile(testFile1).assertThat().existsInRepo();
+ webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile2)
+ .assertThat().existsInWebdav().and()
+ .assertThat().existsInRepo();
+ ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile4)
+ .assertThat().existsInFtp().and()
+ .assertThat().existsInRepo();
+
+ STEP("5. Inside parentFolder create 1 subfolder using WebDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.usingResource(parentFolder).createFolder(testFolder1)
+ .assertThat().existsInWebdav()
+ .and().assertThat().existsInRepo();
+
+ STEP("6. Delete parentFolder using WebDAV 7. Verify folder is deleted along with all its children");
+ webDavProtocol.usingResource(parentFolder).delete().and().assertThat().doesNotExistInRepo()
+ .usingResource(testFolder1).assertThat().doesNotExistInRepo()
+ .usingResource(testFile1).assertThat().doesNotExistInRepo()
+ .usingResource(testFile2).assertThat().doesNotExistInRepo()
+ .usingResource(testFile3).assertThat().doesNotExistInRepo()
+ .usingResource(testFile4).assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 25
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a public test site and adds u2 as manager to his site using CMIS
+ * 3. U1 creates a folder (parentFolder) inside public site's document library using CMIS
+ * 4. U1 creates a subfolder1 and a file1 inside parentFolder using FTP
+ * 5. U1 creates a subfolder2 and a file2 inside subfolder1 using CMIS
+ * 6. U2 creates a subfolder3 and a file3 using WebDAV
+ * 7. U2 deletes parentFolder using FTP
+ * 8. Verify folder is deleted along with all its children
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is able to delete parent folder along with all its children using FTP.")
+ public void deleteFolderWithChildrenUsingFTP() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site using CMIS and adds u2 as manager to his site using REST");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteManager);
+ testUser2.setUserRole(UserRole.SiteManager);
+
+ STEP("3. U1 creates a folder (parentFolder) inside public site's document library using CMIS");
+ FolderModel parentFolder = FolderModel.getRandomFolderModel();
+ cmisAPI.authenticateUser(testUser1)
+ .usingSite(testSitePublic).createFolder(parentFolder)
+ .assertThat().existsInRepo();
+
+ STEP("4. U1 creates a subfolder1 and a file1 inside parentFolder using FTP");
+ FolderModel subFolder1 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+
+ ftpProtocol.authenticateUser(testUser1)
+ .usingResource(parentFolder).createFolder(subFolder1)
+ .assertThat().existsInRepo()
+ .assertThat().existsInFtp()
+ .usingResource(parentFolder).createFile(testFile1)
+ .assertThat().existsInRepo()
+ .assertThat().existsInFtp();
+
+ STEP("5. U1 creates a subfolder2 and a file2 inside subfolder1 using CMIS");
+ FolderModel subFolder2 = FolderModel.getRandomFolderModel();
+ FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD);
+
+ cmisAPI.authenticateUser(testUser1).usingResource(subFolder1)
+ .createFolder(subFolder2)
+ .assertThat().existsInRepo()
+ .createFile(testFile2)
+ .assertThat().existsInRepo();
+
+ STEP("6. U2 creates a subfolder3 and a file3 using WebDAV");
+ FolderModel subFolder3 = FolderModel.getRandomFolderModel();
+ FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML);
+
+ webDavProtocol.authenticateUser(testUser2).usingResource(subFolder2)
+ .createFolder(subFolder3)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo()
+ .createFile(testFile3)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo();
+
+ STEP("7. U2 deletes parentFolder using FTP");
+ ftpProtocol.authenticateUser(testUser2)
+ .usingResource(parentFolder).assertThat().existsInFtp()
+ .then().delete()
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp()
+ .usingResource(subFolder1)
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp()
+ .usingResource(subFolder2)
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp()
+ .usingResource(subFolder3)
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp()
+ .usingResource(testFile1)
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp()
+ .usingResource(testFile2)
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp()
+ .usingResource(testFile3)
+ .assertThat().doesNotExistInRepo().and()
+ .assertThat().doesNotExistInFtp();
+ }
+
+ /**
+ * Scenario 28
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a public test site
+ * 3. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder
+ * 4. Using CMIS, U1 checks out a document from parent folder
+ * 5. Using CMIS, U1 deletes parent folder (deleteTree)
+ * 6. Using WebDAV, U1 verifies that parent folder and all children are NOT present in Repo and WebDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using CMIS.")
+ public void deleteParentFolderWithCheckoutFileInUsingCMIS() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a public test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder");
+ FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content");
+ FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content");
+ FileModel ftpTestFile = FileModel.getRandomFileModel(FileType.MSWORD, "file 4 content");
+
+ testFolder1 = FolderModel.getRandomFolderModel();
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo();
+ cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile)
+ .assertThat().existsInRepo();
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(ftpTestFile)
+ .assertThat().existsInFtp().assertThat().existsInRepo();
+
+ FolderModel cmisTestFolder = FolderModel.getRandomFolderModel();
+ FolderModel webdavTestFolder = FolderModel.getRandomFolderModel();
+ FolderModel ftpTestFolder = FolderModel.getRandomFolderModel();
+
+ cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder)
+ .assertThat().existsInRepo();
+ webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+ ftpProtocol.usingResource(testFolder1).createFolder(ftpTestFolder)
+ .assertThat().existsInFtp().assertThat().existsInRepo();
+
+ cmisAPI.usingResource(testFolder1).assertThat()
+ .hasChildren(cmisTestFile, webdavTestFile, ftpTestFile, cmisTestFolder, webdavTestFolder, ftpTestFolder);
+
+ STEP("Step 4: Using CMIS, U1 checks out a document from parent folder");
+ cmisAPI.usingResource(webdavTestFile).checkOut().assertThat().documentIsCheckedOut();
+
+ STEP("Step 5: Using CMIS, U1 deletes parent folder (deleteTree)");
+
+ cmisAPI.usingResource(testFolder1).deleteFolderTree()
+ .assertThat().doesNotExistInRepo();
+ STEP("Step 6. Using WebDAV, U1 verifies that parent folder and all children are not present");
+ webDavProtocol.usingResource(testFolder1).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav()
+ .and().usingResource(cmisTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav()
+ .and().usingResource(webdavTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav()
+ .and().usingResource(ftpTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav()
+ .and().usingResource(cmisTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav()
+ .and().usingResource(webdavTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav()
+ .and().usingResource(ftpTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav();
+ }
+
+ /**
+ * Scenario 29
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a public test site
+ * 3. Using FTP U1 creates a parent folder in public site's document library
+ * 4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder
+ * 5. Using CMIS, U1 checks out a document from parent folder
+ * 6. Using WebDAV, U1 deletes parent folder (deleteFolder)
+ * 7. Using FTP, U1 verifies that parent folder and all children are NOT present in Repo and FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using WebDAV.")
+ public void deleteParentFolderWithCheckoutFileInUsingWebDAV() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a public test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. Using FTP U1 creates a parent folder");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo();
+
+ STEP("4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder");
+ FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content");
+ FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content");
+ FileModel ftpTestFile = FileModel.getRandomFileModel(FileType.MSWORD, "file 4 content");
+
+ cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile)
+ .assertThat().existsInRepo();
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+ ftpProtocol.usingResource(testFolder1).createFile(ftpTestFile)
+ .assertThat().existsInFtp().assertThat().existsInRepo();
+
+ FolderModel cmisTestFolder = FolderModel.getRandomFolderModel();
+ FolderModel webdavTestFolder = FolderModel.getRandomFolderModel();
+
+ cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder)
+ .assertThat().existsInRepo();
+ webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder).assertThat().existsInWebdav()
+ .and().assertThat().existsInRepo();
+
+ cmisAPI.usingResource(testFolder1).assertThat().hasChildren(cmisTestFile, webdavTestFile, ftpTestFile, cmisTestFolder, webdavTestFolder);
+
+ STEP("Step 5: Using CMIS, U1 checks out a document from parent folder");
+ cmisAPI.usingResource(cmisTestFile).checkOut().assertThat().documentIsCheckedOut();
+
+ STEP("Step 6: Using WebDAV, U1 deletes parent folder (deleteFolder)");
+ webDavProtocol.usingResource(testFolder1).assertThat().existsInRepo().and().assertThat().existsInWebdav()
+ .and().assertThat().hasFiles(cmisTestFile, webdavTestFile, ftpTestFile)
+ .and().assertThat().hasFolders(cmisTestFolder, webdavTestFolder)
+ .then().usingResource(testFolder1).delete()
+ .assertThat().doesNotExistInWebdav().assertThat().doesNotExistInRepo();
+
+ STEP("Step 7. Using FTP, U1 verifies that parent folder and all children are not present");
+ ftpProtocol.usingResource(testFolder1).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp()
+ .and().usingResource(cmisTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp()
+ .and().usingResource(webdavTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp()
+ .and().usingResource(ftpTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp()
+ .and().usingResource(cmisTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp()
+ .and().usingResource(webdavTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp();
+ }
+
+ /**
+ * Scenario 30
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a public test site
+ * 3. Using WebDAV U1 creates a parent folder in public site's document library
+ * 4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder
+ * 5. Using CMIS, U1 checks out a document from parent folder
+ * 6. Using FTP, U1 deletes parent folder (deleteDirectory)
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using FTP.")
+ public void deleteParentFolderWithCheckoutFileInUsingFTP() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a public test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. Using WebDAV U1 creates a parent folder");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo().assertThat()
+ .existsInWebdav();
+
+ STEP("4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder");
+ FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content");
+ FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content");
+
+ cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile)
+ .assertThat().existsInRepo();
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+
+ FolderModel cmisTestFolder = FolderModel.getRandomFolderModel();
+ FolderModel webdavTestFolder = FolderModel.getRandomFolderModel();
+ FolderModel ftpTestFolder = FolderModel.getRandomFolderModel();
+
+ cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder)
+ .assertThat().existsInRepo();
+ webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFolder(ftpTestFolder)
+ .assertThat().existsInFtp().assertThat().existsInRepo();
+
+ cmisAPI.usingResource(testFolder1).assertThat()
+ .hasChildren(cmisTestFile, webdavTestFile, cmisTestFolder, webdavTestFolder, ftpTestFolder);
+
+ STEP("Step 5: Using CMIS, U1 checks out a document from parent folder");
+ cmisAPI.usingResource(webdavTestFile).checkOut().assertThat().documentIsCheckedOut();
+
+ STEP("Step 6: Using FTP, U1 deletes parent folder (deleteDirectory)");
+ ftpProtocol.usingResource(testFolder1).delete()
+ .and().assertThat().doesNotExistInFtp().and().assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 32 - Document updates
+ *
+ * 1. Using CMIS create 2 test users: U1 and U2
+ * 2. Using CMIS and RestAPI U1 creates a public test site and U2 user is added with collaborator role
+ * 3. Using WebDAV U1 creates a folder in his public site's document library
+ * 4. Using WebDAV U1 creates a document inside the above folder
+ * 5. Using RestAPI U2 adds the document to favorites
+ * 6. Using CMIS U1 adds content to document
+ * 7. Using WebDAV U2 validates document's content
+ * 8. Using WebDAV U2 updates content from document
+ * 9. Using CMIS U2 validates document's content
+ * 10. Using WebDAV U1 deletes the file
+ * 11. Using RestAPI U1 deletes the folder
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with collaborator role can update document content in a public site.")
+ public void usersCanUpdateDocumentContentInsideAPublicSite() throws Exception
+ {
+ String originalContent = "originalContent";
+ String updatedContent = "updatedContent";
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+
+ STEP("1. Using CMIS create 2 test users: U1 and U2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS and RestAPI U1 creates a public test site and U2 user is added with collaborator role");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testUser2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2);
+
+ STEP("3. Using WebDAV U1 creates a folder in his public site's document library");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1)
+ .and().assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U1 creates a document inside the above folder");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1)
+ .and().assertThat().existsInWebdav()
+ .and().assertThat().existsInRepo();
+
+ STEP("5. Using RestAPI U2 adds the document to favorites");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFolderToFavorites(testFolder1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("6. Using CMIS U1 adds content to document");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1)
+ .and().assertThat().existsInRepo()
+ .and().update(originalContent);
+
+ STEP("7. Using WebDAV U2 validates document's content");
+ webDavProtocol.authenticateUser(testUser2).usingResource(testFile1).assertThat().contentIs(originalContent);
+
+ STEP("8. Using WebDAV U2 updates content from document");
+ webDavProtocol.usingUser(testUser2).usingResource(testFile1)
+ .assertThat().existsInRepo()
+ .and().update(updatedContent);
+
+ STEP("9. Using CMIS U2 validates document's content");
+ cmisAPI.authenticateUser(testUser2).usingResource(testFile1).assertThat().contentIs(updatedContent);
+
+ STEP("10. Using WebDAV U1 deletes the file");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete()
+ .and().assertThat().doesNotExistInRepo();
+
+ STEP("11. Using WebDAV U1 deletes the folder");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).delete()
+ .and().assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 33 - Document likes
+ *
+ * 1. Using CMIS create 2 test users: U1 and U2
+ * 2. Using RestAPI U1 creates a public test site and U2 user is added with contributor role
+ * 3. Using WebDAV U1 creates a folder in his public site's document library
+ * 4. Using WebDAV U1 creates a document1 inside the above folder
+ * 5. Using WebDAV U2 creates a document2 inside folder
+ * 6. Using RestAPI U2 likes document1
+ * 7. Using RestAPI U1 likes document2
+ * 8. Using RestAPI U1 dislikes document2
+ * 9. Using RestAPI U2 add to favorites document1
+ * 10. Using CMIS U1 delete document1
+ * 11. Using CMIS U2 delete the folder
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = {CmisPermissionDeniedException.class, CmisUnauthorizedException.class} )
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with contributor role can like/favorite a document in a public site.")
+ public void usersCanLikeADocumentInPublicSite() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: U1 and U2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. Using RestAPI U1 creates a public test site and U2 user is added with contributor role");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testUser2.setUserRole(UserRole.SiteContributor);
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2);
+
+ STEP("3. Using WebDAV U1 creates a folder in his public site's document library");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFolder(testFolder1).assertThat().existsInWebdav()
+ .and().assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U1 creates a document1 inside the above folder");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ webDavProtocol.usingResource(testFolder1).createFile(testFile1)
+ .assertThat().existsInRepo()
+ .and().assertThat().existsInWebdav();
+
+ STEP("5. Using WebDAV U2 creates a document2 inside folder");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ webDavProtocol.authenticateUser(testUser2)
+ .usingResource(testFolder1).createFile(testFile2).assertThat().existsInRepo()
+ .and().assertThat().existsInWebdav();
+
+ STEP("6. Using RestAPI U2 likes document1");
+ RestRatingModel returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).likeDocument();
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ returnedRatingModel.assertThat().field("myRating").is("true")
+ .and().field("id").is("likes").and().field("aggregate").isNotEmpty();
+
+ STEP("7. Using RestAPI U1 likes document2");
+ returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile2).likeDocument();
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ returnedRatingModel.assertThat().field("myRating").is("true")
+ .and().field("id").is("likes").and().field("aggregate").isNotEmpty();
+
+ STEP("8. Using RestAPI U1 dislikes document2");
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile2).deleteLikeRating();
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("9. Using RestAPI U2 add to favorites document1");
+ RestPersonFavoritesModel restPersonFavoritesModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ restPersonFavoritesModel.assertThat().field("targetGuid").is(testFile1.getNodeRefWithoutVersion());
+
+ STEP("10. Using CMIS U1 delete document1");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).delete()
+ .and().assertThat().doesNotExistInRepo();
+
+ restAPI.withCoreAPI().usingResource(testFile1).getLikeRating();
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
+ .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef()));
+
+ RestPersonFavoritesModelsCollection userFavorites = restAPI.withCoreAPI().usingAuthUser().getFavorites();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0");
+
+ STEP("11. Using CMIS U2 delete the folder. With Contributor role, U2 does not have permission to delete files/folders created by others.");
+ cmisAPI.authenticateUser(testUser2).usingResource(testFolder1).assertThat().doesNotHaveFile(testFile1)
+ .and().assertThat().hasFiles(testFile2)
+ .and().usingResource(testFile2).delete()
+ .and().usingResource(testFolder1).delete();
+ }
+
+ /**
+ * Scenario 34 - Document ratings
+ *
+ * 1. Using CMIS create 2 test users: U1 and U2
+ * 2. Using RestAPI U1 creates a public test site and U2 user is added with collaborator role
+ * 3. Using CMIS U1 creates a new folder in site
+ * 4. Using WebDAV U2 creates file1 in public site document library
+ * 5. Using WebDAV U1 creates a file2 in public site document library
+ * 6. Using RestAPI U2 rates with 5 stars file2
+ * 7. Using RestAPI U1 rates with 1 star file1
+ * 8. Using RestAPI U2 likes file1
+ * 9. Using RestAPI U2 removes the rating of 5 stars for file2
+ * 10. Using WebDAV U1 delete file1. Using RestAPI get ratings of file1.
+ * 11. Using WebDAV U1 delete the folder
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user with collaborator role can rate a document in a public site.")
+ public void usersCanRateADocumentInPublicSite() throws Exception
+ {
+ RestRatingModel returnedRatingModel;
+
+ STEP("1. Using CMIS create 2 test users: U1 and U2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. Using RestAPI U1 creates a public test site and U2 user is added with collaborator role");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testUser2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2);
+
+ STEP("3. Using CMIS U1 creates a new folder in site");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFolder(testFolder1).assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U2 creates file1 in public site document library");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ webDavProtocol.authenticateUser(testUser2).usingResource(testFolder1)
+ .createFile(testFile1).assertThat().existsInRepo()
+ .and().assertThat().existsInWebdav();
+
+ STEP("5. Using WebDAV U1 creates a file2 in public site document library");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic)
+ .usingResource(testFolder1).createFile(testFile2).assertThat().existsInRepo();
+
+ STEP("6. Using RestAPI U2 rates with 5 stars file2");
+ returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile2)
+ .rateStarsToDocument(5);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
+
+ STEP("7. Using RestAPI U1 rates with 1 star file1");
+ returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile1)
+ .rateStarsToDocument(1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ returnedRatingModel.assertThat().field("myRating").is("1").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
+
+ STEP("8. Using RestAPI U2 likes file1");
+ returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1)
+ .likeDocument();
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
+
+ STEP("9. Using RestAPI U2 removes the rating of 5 stars for file2");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile2).deleteFiveStarRating();
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ returnedRatingModel = restAPI.withCoreAPI().usingResource(testFile2).getFiveStarRating();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0");
+
+ STEP("10. Using WebDAV U1 delete file1. Using RestAPI get ratings of file1.");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete()
+ .and().assertThat().doesNotExistInRepo()
+ .and().assertThat().doesNotExistInWebdav();
+
+ restAPI.withCoreAPI().usingResource(testFile1).getLikeRating();
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
+ .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef()));
+
+ restAPI.withCoreAPI().usingResource(testFile1).getFiveStarRating();
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
+ .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef()));
+
+ STEP("11. Using WebDAV U1 delete the folder");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).assertThat().hasFiles(testFile2)
+ .and().usingResource(testFolder1).delete()
+ .and().assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 35
+ * 1. Using CMIS create 2 test user: U1 and U2
+ * 2. Using CMIS U1 creates a public test site
+ * 3. Using FTP U1 creates a folder in public site's document library: folder1
+ * 4. Using WebDAV U1 creates inside folder1 a new folder: folder2
+ * 5. Using WebDAV U1 creates inside folder2 a new folder: folder3
+ * 6. Using CMIS U1 creates inside folder1 a new file: file1
+ * 7. Using WebDAV U1 creates inside folder2 a new file: file2
+ * 8. Using FTP U1 creates inside folder3 a new file: file3
+ * 9. Using WebDAV U1 deletes file1
+ * 10. Using IMAP U1 deletes file2
+ * 11. Using WebDAV U1 updates content of file3
+ * 12. Using RestAPI U1 adds a comment to file3
+ * 13. Using RestAPI U1 likes file3 and user U2 rates file3
+ * 14. Using CMIS U1 deletes file3
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "File handling - perform actions: create, delete, add comment, like and rate, update file content ")
+ public void fileHandlingCreateUpdateContentDeleteLikeAndRate() throws Exception
+ {
+ STEP("1. Using CMIS create 1 test user: U1 and U2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createIMAPSite();
+
+ STEP("3. Using FTP U1 creates folder: folder1");
+ FolderModel folder1 = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder1)
+ .assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U1 creates folder2 inside folder1");
+ FolderModel folder2 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingResource(folder1).createFolder(folder2);
+
+ STEP("5. Using webDAV U1 creates folder3 inside folder2");
+ FolderModel folder3 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingResource(folder2).createFolder(folder3);
+
+ STEP("6. Using CMIS U1 creates file1 inside folder1");
+ FileModel file1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content");
+ cmisAPI.authenticateUser(testUser1).usingResource(folder1).createFile(file1)
+ .assertThat().existsInRepo();
+
+ STEP("7. Using webDAV U1 creates file2 inside folder2");
+ FileModel file2 = FileModel.getRandomFileModel(FileType.HTML, "file 2 content");
+ webDavProtocol.authenticateUser(testUser1).usingResource(folder2).createFile(file2)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+
+ STEP("8. Using FTP U1 creates file3 inside folder3");
+ FileModel file3 = FileModel.getRandomFileModel(FileType.MSWORD, "file 3 content");
+ ftpProtocol.authenticateUser(testUser1).usingResource(folder3).createFile(file3)
+ .assertThat().existsInRepo();
+
+ STEP("9. Using webDAV U1 deletes file1");
+ webDavProtocol.authenticateUser(testUser1).usingResource(file1).delete()
+ .assertThat().doesNotExistInRepo().and().assertThat().doesNotExistInWebdav();
+
+ STEP("10. Using IMAP U1 deletes file2");
+ imapProtocol.authenticateUser(testUser1).usingResource(file2).deleteMessage()
+ .and().usingResource(file2).assertThat().doesNotExistInRepo();
+
+ STEP("11. Using WebDAV U1 update content of file3");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingResource(file3).assertThat().existsInRepo()
+ .update(newContent).assertThat().contentIs(newContent);
+
+ STEP("12. Using RestAPI U1 adds a comment to file3");
+ String comment = RandomData.getRandomName("comment1");
+ file3.setNodeRef(dataContent.usingUser(testUser1).usingSite(testSitePublic)
+ .usingResource(folder3).usingResource(file3).getNodeRef());
+ RestCommentModel commentModel = restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingResource(file3).addComment(comment);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ commentModel.assertThat().field("content").isNotEmpty()
+ .and().field("content").is(comment);
+
+ STEP("13. Using RestAPI U1 likes file3 and user U2 rates file3");
+ returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(file3).likeDocument();
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty();
+
+ returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingResource(file3).rateStarsToDocument(5);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty();
+
+ STEP("14. Using CMIS U1 deletes file3");
+ cmisAPI.authenticateUser(testUser1).usingResource(file3).delete()
+ .assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 37
+ * 1. Using CMIS creates 2 users: U1 and U
+ * 2. U1 creates a public test site using CMIS
+ * 3. Using CMIS U1 creates folder: folder1
+ * 4. Using WebDAV U1 creates folder2 and folder3 inside folder1
+ * 5. Using FTP U1 creates file1 inside folder1
+ * 6. Using CMIS U1 copies file1 to folder2
+ * 7. Using WebDAV U1 update content of file1 from folder2
+ * 8. Using FTP U1 tries to move file1 from folder2 to folder1
+ * 9. Using WebDAV U1 updates content of file1 from folder1
+ * 10. Using RestAPI U1 adds file1 to favorites
+ * 11. Using RestAPI U1 likes file1 and U2 user rates file1
+ * 12. Using CMIS U1 moves file1 from folder1 to folder3
+ * 13. Using CMIS/RestAPI U1 checks that content, favorites and ratings are kept
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "File handling - perform actions: copy, move, add/update content, favorites, like and rate")
+ public void fileHandlingCopyMoveAddUpdateContentFavoritesLikeAndRate() throws Exception
+ {
+ STEP("1. Using CMIS creates 2 users: U1 and U2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. Using CMIS U1 creates folder: folder1");
+ FolderModel folder1 = FolderModel.getRandomFolderModel();
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder1)
+ .assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U1 creates folder2 and folder3 inside folder1");
+ FolderModel folder2 = FolderModel.getRandomFolderModel();
+ FolderModel folder3 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1)
+ .usingResource(folder1).createFolder(folder2).and().assertThat().existsInWebdav()
+ .usingResource(folder1).createFolder(folder3).and().assertThat().existsInWebdav();
+
+ STEP("5. Using FTP U1 creates file1 inside folder1");
+ FileModel file1 = FileModel.getRandomFileModel(FileType.MSWORD2007, "tasTesting");
+ ftpProtocol.authenticateUser(testUser1).usingResource(folder1).createFile(file1)
+ .assertThat().existsInRepo();
+
+ STEP("6. Using CMIS U1 copies file1 to folder2");
+ FileModel copiedFile = new FileModel(file1);
+ cmisAPI.authenticateUser(testUser1).usingResource(file1).copyTo(folder2);
+ copiedFile.setCmisLocation(cmisAPI.getLastResource());
+ cmisAPI.usingResource(folder2).assertThat().hasFiles(file1);
+
+ STEP("7. Using WebDAV U1 update content of file1 from folder2");
+ webDavProtocol.usingResource(copiedFile).assertThat().existsInRepo()
+ .update(newContent).assertThat().contentIs(newContent);
+
+ STEP("8. Using FTP U1 tries to move file1 from folder2 to folder1");
+ ftpProtocol.authenticateUser(testUser1)
+ .usingResource(copiedFile).moveTo(folder1).assertThat().existsInRepo();
+ Assert.assertTrue(ftpProtocol.usingResource(folder1).getFiles().size() == 1);
+
+ STEP("9. Using WebDAV U1 updates content of file1 from folder1");
+ webDavProtocol.usingResource(file1).update("content folder1")
+ .assertThat().contentIs("content folder1");
+
+ STEP("10. Using RestAPI U1 adds file1 to favorites");
+ file1.setNodeRef(dataContent.usingUser(testUser1).usingSite(testSitePublic)
+ .usingResource(folder1).usingResource(file1).getNodeRef());
+
+ restPersonFavoritesModel = restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingAuthUser().addFileToFavorites(file1);
+ restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED);
+ restPersonFavoritesModel.assertThat().field("targetGuid").is(file1.getNodeRefWithoutVersion());
+
+ STEP("11. Using RestAPI U1 likes file1 and U2 user rates file1");
+ returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingResource(file1).likeDocument();
+ restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED);
+ returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes")
+ .and().field("aggregate").isNotEmpty();
+
+ returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingResource(file1).rateStarsToDocument(5);
+ restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED);
+ returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar")
+ .and().field("aggregate").isNotEmpty();
+
+ STEP("12. Using CMIS U1 moves file1 from folder1 to folder3");
+ cmisAPI.usingSite(testSitePublic).usingResource(file1).moveTo(folder3)
+ .and().assertThat().existsInRepo();
+
+ STEP("13. Using CMIS/RestAPI U1 checks that content, favorites and ratings are kept");
+ returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar")
+ .and().field("aggregate").isNotEmpty();
+ restPersonFavoritesModel.assertThat().field("targetGuid").is(file1.getNodeRefWithoutVersion());
+ }
+
+ /**
+ * Scenario 38
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a new document in Share
+ * 3. Using WebDAV U1 creates a new document in User Home
+ * 4. Using WebDAV U1 updates both documents
+ * 5. Verify if only first document's version is increased using CMIS
+ * 6. Verify if content is updated using WebDav
+ * 7. Verify if the size of the document is increased
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify document versioning after appending content using WebDAV.")
+ public void checkDocumentVersionAfterAppendingContent() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a new document in Share");
+ FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content");
+ cmisAPI.authenticateUser(testUser1)
+ .usingShared().createFile(cmisTestFile)
+ .assertThat().existsInRepo();
+
+ STEP("3. Using WebDAV U1 creates a new document in User Home");
+ FileModel webDAVTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 2 content");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingUserHome().createFile(webDAVTestFile)
+ .assertThat().existsInWebdav().and()
+ .assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U1 updates both documents");
+ webDavProtocol.usingResource(cmisTestFile).update("cmis file content")
+ .usingResource(webDAVTestFile).update("WebDAV file content");
+
+ STEP("5. Verify if only first document's version is increased using CMIS");
+ cmisAPI.usingResource(cmisTestFile).assertThat().documentHasVersion(1.1)
+ .usingResource(webDAVTestFile).assertThat().documentHasVersion(1.0);
+
+ STEP("6. Verify if content is updated using WebDav");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingResource(cmisTestFile).assertThat().contentIs("cmis file content")
+ .usingResource(webDAVTestFile).assertThat().contentIs("WebDAV file content");
+
+ STEP("7. Verify if the size of the document is increased");
+ cmisAPI.usingResource(cmisTestFile).assertThat().contentLengthIs(17)
+ .usingResource(webDAVTestFile).assertThat().contentLengthIs(19);
+ }
+
+ /**
+ * Scenario 40
+ * 1. Using CMIS create test user: U1
+ * 2. U1 creates a private test site using CMIS
+ * 3. Using WebDAV U1 creates a folder
+ * 4. Using WebDAV U1 creates a file inside the folder
+ * 5. Using CMIS, check out the document
+ * 6. Using CMIS verify if PWC is created
+ * 7. Using CMIS check in document with content
+ * 8. Using CMIS verify that version does not increase
+ * 9. Using CMIS verify new content is added to document
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify increased version and new content of a file that was check out then check in.")
+ public void verifyIncreasedVersionAndNewContentOfCheckInDocument() throws Exception
+ {
+ STEP("Step 1. Using CMIS create test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("Step 2. U1 creates a private test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("Step 3. Using WebDAV U1 creates a folder");
+ FolderModel folder = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder);
+
+ STEP("Step 4. Using WebDAV U1 creates a file inside the folder");
+ FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content");
+ webDavProtocol.authenticateUser(testUser1).usingResource(folder).createFile(file)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+
+ STEP("Step 5: Using CMIS, check out the document and verify document version");
+ cmisAPI.authenticateUser(testUser1).usingResource(file).checkOut()
+ .assertThat().documentIsCheckedOut();
+
+ STEP("Step 6: Using CMIS verify if PWC is created");
+ FileModel filePWC = cmisAPI.usingResource(file).withCMISUtil().getPWCFileModel();
+ cmisAPI.usingResource(filePWC).assertThat().existsInRepo();
+
+ STEP("Step 7: Using CMIS check in document with content");
+ String newContent = "new major content";
+ cmisAPI.usingResource(folder).assertThat().folderHasCheckedOutDocument(file);
+ cmisAPI.usingResource(file).prepareDocumentForCheckIn()
+ .withMajorVersion()
+ .withContent(newContent)
+ .checkIn().refreshResource()
+ .and().assertThat().documentIsNotCheckedOut();
+
+ STEP("Step 8: Using CMIS verify that version does not increase");
+ cmisAPI.usingResource(file).assertThat().documentHasVersion(1.0);
+
+ STEP("Step 9: Using CMIS verify new content is added to document");
+ cmisAPI.usingResource(file).assertThat().contentIs(newContent);
+ }
+
+ /**
+ * Scenario 41
+ * 1. Using CMIS create test user: U1
+ * 2. U1 creates a private test site using CMIS
+ * 3. Using WebDAV U1 creates a folder
+ * 4. Using WebDAV U1 creates a file inside the folder
+ * 5. Using CMIS, check out the document
+ * 6. Using CMIS verify if PWC is created
+ * 7. Using CMIS, cancel check out
+ * 8. Using CMIS, verify original document has version 1.0
+ * 9. Using CMIS, verify original document has same content
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify that version and the content of a file are not changed if the checkout is canceled.")
+ public void verifyVersionAndContentOfACanceledCheckoutDocument() throws Exception
+ {
+ STEP("Step 1. Using CMIS create test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("Step 2. U1 creates a private test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("Step 3. Using WebDAV U1 creates a folder");
+ FolderModel folder = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder);
+
+ STEP("Step 4. Using WebDAV U1 creates a file inside the folder");
+ FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content");
+ webDavProtocol.authenticateUser(testUser1).usingResource(folder).createFile(file)
+ .assertThat().existsInWebdav().assertThat().existsInRepo();
+
+ STEP("Step 5: Using CMIS, check out the document");
+ cmisAPI.authenticateUser(testUser1).usingResource(file).checkOut();
+
+ STEP("Step 6: Using CMIS verify if PWC is created");
+ FileModel filePWC = cmisAPI.usingResource(file).withCMISUtil().getPWCFileModel();
+ cmisAPI.usingResource(filePWC).assertThat().existsInRepo();
+
+ STEP("Step 7: Using CMIS, cancel check out");
+ cmisAPI.usingResource(file).cancelCheckOut().then()
+ .assertThat().documentIsNotCheckedOut();
+
+ STEP("Step 8: Using CMIS, verify original document has version 1.0");
+ cmisAPI.usingResource(file).assertThat().isNotPrivateWorkingCopy()
+ .then().assertThat().documentHasVersion(1.0);
+
+ STEP("Step 9: Using CMIS, verify original document has same content");
+ cmisAPI.usingResource(file).assertThat().contentIs("file content");
+ }
+
+ /**
+ * Scenario 42
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a file: file
+ * 3. Using WebDAV U1 renames file and verify if the new document exists
+ * 4. Using FTP verify old document does not exists
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Edit document name and verify document with new name")
+ public void renameDocument() throws Exception
+ {
+ STEP("1. Using CMIS create test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates file");
+ FileModel file = FileModel.getRandomFileModel(FileType.PDF, "file content");
+ cmisAPI.authenticateUser(testUser1).usingUserHome().createFile(file)
+ .assertThat().existsInRepo();
+
+ STEP("3. Using WebDAV U1 renames file and verify if the new document exists");
+ FileModel oldFile = new FileModel(file);
+ webDavProtocol.authenticateUser(testUser1).usingResource(file).rename(renamePrefix + file.getName())
+ .and().assertThat().existsInRepo().and().assertThat().existsInWebdav();
+
+ STEP("4. Using FTP verify old document does not exists");
+ ftpProtocol.authenticateUser(testUser1).usingResource(oldFile)
+ .assertThat().doesNotExistInRepo()
+ .and().assertThat().doesNotExistInFtp();
+ }
+
+ /**
+ * Scenario 43
+ * 1. Using CMIS create test user: U1
+ * 2. Using WebDAV U1 creates a file using shared
+ * 3. Using webDAV append content to document
+ * 4. Using CMIS, verify original document has version 1.0
+ * 5. Using CMIS delete document
+ * 6. Using WebDAV, verify document is deleted
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Delete document after append content and verify document version.")
+ public void deleteDocumentAfterAppendContent() throws Exception
+ {
+ STEP("Step 1. Using CMIS create test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("Step 2. Using WebDAV U1 creates a file using shared");
+ FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content");
+ webDavProtocol.authenticateUser(testUser1).usingUserHome().createFile(file)
+ .assertThat().existsInRepo();
+
+ STEP("Step 3. Using webDAV append content to document");
+ String newContentToAppend = " - append this text to the file";
+ webDavProtocol.authenticateUser(testUser1).usingResource(file).assertThat().contentIs("file content")
+ .then().update(file.getContent() + newContentToAppend)
+ .assertThat().contentIs(file.getContent() + newContentToAppend);
+
+ STEP("Step 4: Using CMIS, verify original document has version 1.0");
+ cmisAPI.authenticateUser(testUser1).usingResource(file).assertThat().isNotPrivateWorkingCopy()
+ .then().assertThat().documentHasVersion(1.0);
+
+ STEP("Step 4: Using CMIS, delete document");
+ cmisAPI.usingResource(file).assertThat().existsInRepo().delete();
+
+ STEP("Step 5: Using WebDAV, verify document is deleted");
+ webDavProtocol.authenticateUser(testUser1).usingResource(file).assertThat().doesNotExistInWebdav()
+ .and().assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 44
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a public test site
+ * 3. Using WebDAV U1 creates a new file in User Home
+ * 4. Using WebDAV U1 creates another file in public site document library.
+ * 5. Using CMIS U1 creates a relationship between documents
+ * 6. Verify if relationship is created
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify if relationship is created between 2 items using CMIS.")
+ public void checkRelationshipBetween2Files() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a public test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. Using WebDAV U1 creates a new file in User Home");
+ FileModel sourceFile= FileModel.getRandomFileModel(FileType.PDF, "file content");
+ webDavProtocol.authenticateUser(testUser1).usingUserHome()
+ .createFile(sourceFile).assertThat().existsInRepo();
+
+ STEP("4. Using WebDAV U1 creates another file in public site document library.");
+ FileModel targetFile= FileModel.getRandomFileModel(FileType.PDF, "file content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFile(targetFile).assertThat().existsInRepo();
+
+ STEP("5. Using CMIS U1 creates a relationship between documents. 6. Verify if relationship is created");
+ cmisAPI.authenticateUser(testUser1).usingResource(sourceFile).createRelationshipWith(targetFile)
+ .assertThat().objectHasRelationshipWith(targetFile);
+ }
+
+ /**
+ * Scenario 46
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates an imap test site
+ * 3. Using CMIS U1 creates cmisFolder in Shared
+ * 4. Using IMAP U1 creates parentFolder in private site document library.
+ * 5. Using FTP U1 creates a subfolder in parentFolder
+ * 6. Using WebDAV U1 creates a webdavFolder in User Home
+ * 7. Using WebDAV U1 creates a document in parentFolder
+ * 8. Using CMIS U1 adds document to cmisFolder, subfolder, webdavFolder
+ * 9. Using WebDAV verify document is present in all folders
+ * 10. Using CMIS U1 removes document from subFolder
+ * 11. Using WebDAV verify document is not present in subFolder
+ * 12. Using FTP U1 deletes original document from parentFolder
+ * 13. Using CMIS verify document does not exist
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify parents list for an object using CMIS.")
+ public void addAndRemoveDocumentFromFolders() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates an imap test site");
+ testSitePublic = dataSite.usingUser(testUser1).createIMAPSite();
+
+ STEP("3. Using CMIS U1 creates cmisFolder in Shared");
+ FolderModel cmisFolder = FolderModel.getRandomFolderModel();
+ cmisAPI.authenticateUser(testUser1)
+ .usingShared().createFolder(cmisFolder)
+ .assertThat().existsInRepo();
+
+ STEP("4. Using IMAP U1 creates parentFolder in private site document library.");
+ FolderModel parentFolder = FolderModel.getRandomFolderModel();
+ imapProtocol.authenticateUser(testUser1)
+ .usingSite(testSitePublic).createFolder(parentFolder)
+ .assertThat().existsInRepo();
+
+ STEP("5. Using FTP U1 creates a subfolder in parentFolder");
+ FolderModel subFolder = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser1)
+ .usingResource(parentFolder).createFolder(subFolder)
+ .assertThat().existsInRepo();
+
+ STEP("6. Using WebDAV U1 creates a webdavFolder in User Home");
+ FolderModel webdavFolder = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1)
+ .usingUserHome().createFolder(webdavFolder)
+ .assertThat().existsInRepo();
+
+ STEP("7. Using WebDAV U1 creates a document in parentFolder");
+ testFile1= FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingResource(parentFolder).createFile(testFile1)
+ .assertThat().existsInRepo();
+
+ STEP("8. Using CMIS U1 adds document to cmisFolder, subfolder, webdavFolder");
+ cmisAPI.usingResource(testFile1)
+ .addDocumentToFolder(cmisFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName())
+ .addDocumentToFolder(subFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), subFolder.getName())
+ .addDocumentToFolder(webdavFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), subFolder.getName(), webdavFolder.getName());
+
+ STEP("9. Using WebDAV verify document is present in all folders");
+ FileModel fileAddedInCMISFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent());
+ fileAddedInCMISFolder.setCmisLocation(Utility.buildPath(cmisFolder.getCmisLocation(), testFile1.getName()));
+
+ FileModel fileAddedInSubFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent());
+ fileAddedInSubFolder.setCmisLocation(Utility.buildPath(subFolder.getCmisLocation(), testFile1.getName()));
+
+ FileModel fileAddedInWebDAVFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent());
+ fileAddedInWebDAVFolder.setCmisLocation(Utility.buildPath(webdavFolder.getCmisLocation(), testFile1.getName()));
+
+ webDavProtocol.usingResource(fileAddedInCMISFolder).assertThat().existsInWebdav()
+ .usingResource(fileAddedInSubFolder).assertThat().existsInWebdav()
+ .usingResource(fileAddedInWebDAVFolder).assertThat().existsInWebdav();
+
+ STEP("10. Using CMIS U1 removes document from subFolder");
+ cmisAPI.usingResource(testFile1).removeDocumentFromFolder(subFolder)
+ .assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), webdavFolder.getName());
+
+ STEP("11. Using WebDAV verify document is not present in subFolder");
+ webDavProtocol.usingResource(testFile1).assertThat().existsInWebdav()
+ .usingResource(fileAddedInCMISFolder).assertThat().existsInWebdav()
+ .usingResource(fileAddedInSubFolder).assertThat().doesNotExistInWebdav()
+ .usingResource(fileAddedInWebDAVFolder).assertThat().existsInWebdav();
+
+ STEP("12. Using FTP U1 deletes original document from parentFolder");
+ ftpProtocol.usingResource(testFile1).delete().assertThat().doesNotExistInFtp();
+
+ STEP("13. Using CMIS verify document does not exist");
+ cmisAPI.usingResource(fileAddedInCMISFolder).assertThat().doesNotExistInRepo()
+ .usingResource(fileAddedInWebDAVFolder).assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 47 - Delete many documents
+ *
+ * 1. Using CMIS create test user: U1
+ * 2. Using CMIS U1 creates a public test site
+ * 3. Using CMIS and WebDAV U1 creates parentFolder1, doc1 and doc2 in document library
+ * 4. Using WebDAV and FTP U1 creates inside parentFolder1: childDoc1 to childDoc5
+ * 5. Using IMAP bulk delete doc1 and doc2
+ * 6. Using CMIS verify that doc1 and doc2 are deleted
+ * 7. Using IMAP delete childDoc1 to childDoc4
+ * 8. Using WebDAV and FTP verify if docs are deleted from their folders
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION,
+ description = "Verify users can delete many documents in a public site using different protocols.")
+ public void usersCanDeleteManyDocuments() throws Exception
+ {
+ FolderModel parentFolder1 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ FileModel childDoc1, childDoc2, childDoc3, childDoc4, childDoc5;
+ childDoc1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ childDoc2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ childDoc3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ childDoc4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ childDoc5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+
+ STEP("1. Using CMIS create test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a public test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. Using CMIS and WebDAV U1 creates parentFolder1, doc1 and doc2 in document library");
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(parentFolder1)
+ .and().assertThat().existsInRepo();
+
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1)
+ .and().createFile(testFile2);
+
+ STEP("4. Using WebDAV and FTP U1 creates inside parentFolder1: childDoc1 to childDoc5");
+ webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder1)
+ .createFile(childDoc1).and().createFile(childDoc2);
+
+ ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder1)
+ .createFile(childDoc3).and().createFile(childDoc4).and().createFile(childDoc5);
+
+ STEP("5. Using IMAP bulk delete doc1 and doc2");
+ imapProtocol.authenticateUser(testUser1).usingSite(testSitePublic).deleteMessage(testFile1.getName(), testFile2.getName()).assertThat().doesNotContainMessages(testFile1, testFile2);
+ Utility.waitToLoopTime(10);
+
+ STEP("6. Using CMIS verify that doc1 and doc2 are deleted");
+ cmisAPI.authenticateUser(testUser1)
+ .usingResource(testFile1).assertThat().doesNotExistInRepo()
+ .and().usingResource(testFile2).assertThat().doesNotExistInRepo();
+
+ STEP("7. Using IMAP delete childDoc1 to childDoc4");
+ imapProtocol.authenticateUser(testUser1).usingResource(parentFolder1).deleteMessage(childDoc1.getName(), childDoc2.getName(), childDoc3.getName(), childDoc4.getName())
+ .assertThat().doesNotContainMessages(childDoc1, childDoc2, childDoc3, childDoc4);
+ Utility.waitToLoopTime(10);
+
+ STEP("8. Using WebDAV and FTP verify if docs are deleted from their folders");
+ webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder1).assertThat().hasFiles(childDoc5)
+ .and().usingResource(childDoc1).assertThat().doesNotExistInRepo()
+ .and().usingResource(childDoc2).assertThat().doesNotExistInRepo();
+
+ ftpProtocol.authenticateUser(testUser1).usingResource(childDoc3)
+ .assertThat().doesNotExistInRepo()
+ .and().usingResource(childDoc4).assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 48 - Move folder in another folder
+ *
+ * 1. Using CMIS create user u1 and public site
+ * 2. Using WebDAV U1 creates folder1 and folder2
+ * 3. Using WebDAV U1 creates doc1 in folder1
+ * 4. Using FTP U1 moves folder1 in folder2
+ * 5. Using WebDAV verify that folder1 is not in the original location and is present in folder2
+ * 6. Using CMIS verify if doc1 is still present in folder1
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to move a non empty folder to another folder from the same site.")
+ public void moveFolderInAnotherFolder() throws Exception
+ {
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFolder2 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+
+ STEP("1. Using CMIS create user u1 and public site");
+ testUser1 = dataUser.createRandomTestUser();
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("2. Using WebDAV U1 creates folder1 and folder2");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFolder(testFolder1)
+ .and().assertThat().existsInRepo().and().assertThat().existsInWebdav()
+ .then().createFolder(testFolder2)
+ .and().assertThat().existsInRepo().and().assertThat().existsInWebdav();
+
+ STEP("3. Using WebDAV U1 creates doc1 in folder1");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1)
+ .and().assertThat().existsInRepo().and().assertThat().existsInWebdav()
+ .and().usingResource(testFolder1).assertThat().hasFiles(testFile1);
+
+ STEP("4. Using FTP U1 moves folder1 in folder2");
+ ftpProtocol.authenticateUser(testUser1)
+ .usingResource(testFolder1).moveTo(testFolder2)
+ .assertThat().existsInRepo()
+ .then().usingResource(testFolder1).assertThat().doesNotExistInRepo();
+
+ STEP("5. Using WebDAV verify that folder1 is not in the original location and is present in folder2");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).assertThat().doesNotExistInRepo()
+ .and().usingResource(testFolder2).assertThat().hasFolders(testFolder1);
+
+ STEP("6. Using CMIS verify if doc1 is still present in folder1");
+ FolderModel newTestFolder1 = new FolderModel(testFolder1.getName(), testFolder1.getTitle(), testFolder1.getDescription());
+ newTestFolder1.setCmisLocation(Utility.buildPath(testFolder2.getCmisLocation(), testFolder1.getName()));
+
+ FileModel newTestFile1 = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent());
+ newTestFile1.setCmisLocation(Utility.buildPath(newTestFolder1.getCmisLocation(), testFile1.getName()));
+
+ cmisAPI.authenticateUser(testUser1).usingResource(newTestFolder1)
+ .assertThat().existsInRepo()
+ .assertThat().hasFiles(newTestFile1);
+ }
+
+ /**
+ * Scenario 49 - Copy folder in another folder
+ *
+ * 1. Using CMIS create user u1 and public site
+ * 2. Using CMIS U1 creates folder1 and folder2
+ * 3. Using WebDAV U1 creates doc1 in folder1
+ * 4. Using WebDAV U1 copies folder1 in folder2
+ * 5. Using FTP verify that folder1 is in the original location and contains doc1
+ * 6. Using WebDAV verify that folder1 is in folder2 and contains doc1
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to copy non empty folder to another folder in the same site.")
+ public void copyFolderInAnotherFolder() throws Exception
+ {
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFolder2 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+
+ STEP("1. Using CMIS create user u1 and public site");
+ testUser1 = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20));
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("2. Using CMIS U1 creates folder1 and folder2");
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFolder(testFolder1).and().assertThat().existsInRepo().and()
+ .createFolder(testFolder2).and().assertThat().existsInRepo();
+
+ STEP("3. Using WebDAV U1 creates doc1 in folder1");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1)
+ .createFile(testFile1).and().assertThat().existsInRepo()
+ .and().assertThat().existsInWebdav();
+
+ STEP("4. Using WebDAV U1 copies folder1 in folder2");
+ testFolder2.setProtocolLocation(webDavProtocol.getPrefixSpace() + testFolder2.getCmisLocation());
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).copyTo(testFolder2)
+ .assertThat().existsInRepo()
+ .then().usingResource(testFolder1).assertThat().existsInRepo();
+
+ STEP("5. Using FTP verify that folder1 is in the original location and contains doc1");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1)
+ .assertThat().existsInRepo()
+ .and().assertThat().existsInFtp()
+ .and().assertThat().hasFiles(testFile1);
+
+ STEP("6. Using WebDAV verify that folder1 is in folder2 and contains doc1");
+ FolderModel newTestFolder1 = new FolderModel(testFolder1.getName(), testFolder1.getTitle(), testFolder1.getDescription());
+ newTestFolder1.setCmisLocation(Utility.buildPath(testFolder2.getCmisLocation(), testFolder1.getName()));
+
+ FileModel newTestFile1 = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent());
+ newTestFile1.setCmisLocation(Utility.buildPath(newTestFolder1.getCmisLocation(), testFile1.getName()));
+
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder2)
+ .assertThat().hasFolders(newTestFolder1)
+ .and().usingResource(newTestFolder1)
+ .assertThat().existsInRepo().and().assertThat().existsInWebdav()
+ .and().assertThat().hasFiles(newTestFile1);
+ }
+
+ /**
+ * Scenario 50 - Rename site
+ *
+ * 1. Using CMIS create one test user: U1
+ * 2. Using CMIS U1 creates a moderated site
+ * 3. Using WebDAV U1 creates a folder in the moderated site document library
+ * 4. Using CMIS U1 tries to rename site
+ * 5. Verify that a site cannot be renamed
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = CmisRuntimeException.class, expectedExceptionsMessageRegExp = "^.*Sites can not be renamed.$")
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify sites cannot be renamed using CMIS.")
+ public void renameSite() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: U1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using CMIS U1 creates a moderated site");
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+
+ STEP("3. Using WebDAV U1 creates a folder in the moderated site document library");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1)
+ .usingSite(testSiteModerated).createFolder(testFolder1)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo();
+
+ STEP("4. Using CMIS U1 tries to rename site 5. Verify that a site cannot be renamed");
+ FolderModel siteFolder = new FolderModel(String.format("/Sites/%s", testSiteModerated.getId()));
+ cmisAPI.authenticateUser(testUser1).usingResource(siteFolder).rename("renamedSite");
+ }
+}
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTests.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTests.java
new file mode 100644
index 0000000000..529c5ef412
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTests.java
@@ -0,0 +1,1800 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
+
+import io.restassured.RestAssured;
+import java.io.File;
+
+import javax.json.JsonObject;
+import javax.mail.Flags;
+import javax.mail.MessagingException;
+
+import org.alfresco.dataprep.CMISUtil;
+import org.alfresco.dataprep.SiteService.Visibility;
+import org.alfresco.rest.core.JsonBodyGenerator;
+import org.alfresco.rest.core.RestRequest;
+import org.alfresco.rest.core.RestResponse;
+import org.alfresco.rest.model.RestCommentModel;
+import org.alfresco.rest.model.RestErrorModel;
+import org.alfresco.rest.model.RestItemModelsCollection;
+import org.alfresco.rest.model.RestNetworkModelsCollection;
+import org.alfresco.rest.model.RestPreferenceModel;
+import org.alfresco.rest.model.RestPreferenceModelsCollection;
+import org.alfresco.rest.model.RestProcessDefinitionModelsCollection;
+import org.alfresco.rest.model.RestProcessModel;
+import org.alfresco.rest.model.RestProcessVariableCollection;
+import org.alfresco.rest.model.RestProcessVariableModel;
+import org.alfresco.rest.model.RestTaskModel;
+import org.alfresco.rest.model.RestTaskModelsCollection;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.constants.PreferenceName;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.data.RandomData;
+import org.alfresco.utility.model.*;
+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.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException;
+import org.apache.commons.net.ftp.FTPReply;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.testng.Assert;
+import org.testng.SkipException;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+/**
+ * Created by Claudia Agache on 2/7/2017.
+ */
+public class IntegrationFullTests extends IntegrationTest
+{
+ private UserModel admin, testUser1, testUser2, userToAssign;
+ private SiteModel publicSite, moderatedSite, privateSite;
+ private FileModel testFile1, testFile2;
+ private FolderModel parentFolder;
+ private RestTaskModelsCollection processTasks;
+ private RestProcessModel processModel;
+ private RestItemModelsCollection taskItems;
+ private TaskModel taskModel;
+ private RestTaskModel restTaskModel;
+
+ @BeforeClass(alwaysRun = true)
+ public void setup() throws Exception
+ {
+ admin = dataUser.getAdminUser();
+ }
+
+ /**
+ * Scenario
+ * 1. Using CMIS create test user testUser
+ * 2. Using CMIS create public IMAP site testSite
+ * 3. Using CMIS create file testFile in testSite document library
+ * 4. Using IMAP delete testFile
+ * 5. Using CMIS try to rename testFile
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL }, expectedExceptions = CmisObjectNotFoundException.class)
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify the file cannot be renamed in repository if it is deleted from IMAP client")
+ public void verifyFileCannotBeRenamedInRepoIfItWasAlreadyDeletedViaIMAP() throws Exception
+ {
+ UserModel testUser = dataUser.createRandomTestUser();
+ SiteModel testSite = dataSite.usingUser(testUser).createIMAPSite();
+ FileModel testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN));
+ imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).deleteMessage();
+ cmisAPI.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).rename("new file name");
+ }
+
+ /**
+ * Scenario 51
+ * 1. Using CMIS create a test user: u1
+ * 2. U1 creates a private site using CMIS
+ * 3. U1 creates a folder in site's document library using WebDAV
+ * 4. U1 uploads a document with size > x MB in folder1 using FTP
+ * 5. Verify file is present in folder1 using WebDAV
+ * 6. Verify size of the document from folder1 is exact as the size of the uploaded document CMIS
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify a 1MB file is uploaded in a private site")
+ public void userShouldUploadFileInPrivateSite() throws Exception
+ {
+ STEP("1. Using CMIS create a test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a private site using CMIS");
+ privateSite = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("3. U1 creates a folder in site's document library using WebDav");
+ parentFolder = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1)
+ .usingSite(privateSite).createFolder(parentFolder)
+ .assertThat().existsInWebdav();
+
+ STEP("4. U1 uploads a document with size > x MB in folder1 using FTP");
+ File fileForUpload = Utility.getTestResourceFile("shared-resources/testdata/flower.jpg");
+ ftpProtocol.authenticateUser(testUser1)
+ .usingResource(parentFolder).uploadFile(fileForUpload)
+ .assertThat().existsInRepo()
+ .and().assertThat().existsInFtp();
+ testFile1 = new FileModel(fileForUpload.getName());
+ testFile1.setCmisLocation(ftpProtocol.getLastResourceWithoutPrefix());
+
+ STEP("5. Verify file is present in folder1 using WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder).assertThat().hasFiles(testFile1);
+
+ STEP("6. Verify size of the document from folder1 is exact as the size of the uploaded document CMIS");
+ cmisAPI.authenticateUser(testUser1)
+ .usingResource(testFile1).assertThat().contentLengthIs(fileForUpload.length());
+ }
+
+ /**
+ * Scenario 52
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a private site using CMIS
+ * 3. U1 creates 2 documents in his site using WebDAV
+ * 4. U1 creates a new task with the documents created above and assigns the task to U2 using REST
+ * 5. Verify that U2 doesn't have access to te documents attached to the task using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is not able to access files from a private site, even if they are attached to a task assigned to him.")
+ public void assigneeCantAccessFilesFromPrivateSiteIfHeIsNotAMember() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a private site using CMIS");
+ privateSite = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("3. U1 creates 2 documents in his site using WebDav");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file2 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(privateSite)
+ .createFile(testFile1)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo()
+ .createFile(testFile2)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that U2 doesn't have access to te documents attached to the task using FTP");
+ ftpProtocol.authenticateUser(testUser2)
+ .usingResource(testFile1).assertThat().hasReplyCode(FTPReply.FILE_UNAVAILABLE).and().assertThat().doesNotExistInFtp()
+ .usingResource(testFile2).assertThat().hasReplyCode(FTPReply.FILE_UNAVAILABLE).and().assertThat().doesNotExistInFtp();
+ }
+
+ /**
+ * Scenario 53
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a moderated site using CMIS
+ * 3. U1 creates 2 documents in his site using WebDAV
+ * 4. U1 creates a new task with the documents created above and assigns the task to U2 using REST
+ * 5. Verify that U2 doesn't have access to te documents attached to the task using WebDav
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL }, expectedExceptionsMessageRegExp = "^Access is denied.$")
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is not able to access files from a moderated site, even if they are attached to a task assigned to him.")
+ public void assigneeCantAccessFilesFromModeratedSiteIfHeIsNotAMember() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a moderated site using CMIS");
+ moderatedSite = dataSite.usingUser(testUser1).createModeratedRandomSite();
+
+ STEP("3. U1 creates 2 documents in his site using WebDAV");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file2 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(moderatedSite)
+ .createFile(testFile1)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo()
+ .createFile(testFile2)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that U2 doesn't have access to te documents attached to the task using WebDav");
+ webDavProtocol.authenticateUser(testUser2)
+ .usingResource(testFile1).assertThat().doesNotExistInWebdav()
+ .usingResource(testFile2).assertThat().doesNotExistInWebdav();
+ }
+
+ /**
+ * Scenario 54
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates 2 documents in his site using CMIS
+ * 4. U1 creates a new task with the documents created above and assigns the task to U2 using REST
+ * 5. Verify that U2 have access to te documents attached to the task using WebDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is able to access files from a public site, even if they are attached to a task assigned to him.")
+ public void assigneeCanAccessFilesFromPublicSiteIfHeIsNotAMember() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates 2 documents in his site using CMIS");
+ testFile1 = FileModel.getRandomFileModel(FileType.MSWORD, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.MSWORD, "file2 content");
+ cmisAPI.authenticateUser(testUser1).usingSite(publicSite)
+ .createFile(testFile1)
+ .assertThat().existsInRepo()
+ .usingSite(publicSite).createFile(testFile2)
+ .assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ testFile1.setNodeRef(dataContent.usingResource(testFile1).getNodeRef());
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ testFile2.setNodeRef(dataContent.usingResource(testFile2).getNodeRef());
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that U2 have access to te documents attached to the task using WebDAV");
+ webDavProtocol.authenticateUser(testUser2)
+ .usingSite(publicSite).assertThat().hasFiles(testFile1, testFile2);
+ }
+
+ /**
+ * Scenario 55
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates 2 documents in User Home with CMIS
+ * 3. U1 creates a new task with the documents created above and assigns the task to U2 using REST
+ * 4. Verify that U2 doesn't have access to te documents attached to the task using CMIS
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL }, expectedExceptions = {CmisPermissionDeniedException.class, CmisUnauthorizedException.class})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is not able to access files from another user User Home repo, even if they are attached to a task assigned to him.")
+ public void assigneeCantAccessFilesFromAnotherUserHome() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates 2 documents in User Home with CMIS");
+ testFile1 = FileModel.getRandomFileModel(FileType.MSWORD, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.MSWORD, "file2 content");
+
+ cmisAPI.authenticateUser(testUser1).usingUserHome()
+ .createFile(testFile1)
+ .assertThat().existsInRepo()
+ .createFile(testFile2)
+ .assertThat().existsInRepo();
+
+ STEP("3. U1 creates a new task with the documents created above and assigns the task to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. Verify that U2 doesn't have access to te documents attached to the task using CMIS");
+ cmisAPI.authenticateUser(testUser2)
+ .usingResource(testFile1).assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 56
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates document1 in a public site using CMIS
+ * 3. U2 is added to that public site with manager role using REST
+ * 4. U2 opens the document and renames it to document2 using WebDAV
+ * 5. Verify that U1 can't delete anymore document1 using FTP
+ * 6. U1 deletes document2 using WebDAV
+ * 7. Verify U2 can't update document2 using WebDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Check that user can't delete/update a file that is renamed/deleted by another user.")
+ public void deleteFileAfterItIsRenamedByAnotherUser() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates document1 in a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ cmisAPI.authenticateUser(testUser1).usingSite(publicSite)
+ .createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("3. U2 is added to that public site with manager role using REST");
+ testUser2.setUserRole(UserRole.SiteManager);
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(publicSite).addPerson(testUser2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. U2 opens the document and renames it to document2 using WebDAV");
+ FileModel oldFile = new FileModel(testFile1);
+ webDavProtocol.authenticateUser(testUser2)
+ .usingResource(testFile1).rename("new" + testFile1.getName())
+ .assertThat().existsInRepo();
+
+ STEP("5. Verify that U1 can't delete anymore document1 using FTP");
+ ftpProtocol.authenticateUser(testUser1)
+ .usingResource(oldFile).delete()
+ .assertThat().hasReplyCode(550);
+
+ STEP("6. U1 deletes document2 using WebDAV");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingResource(testFile1).delete()
+ .assertThat().doesNotExistInWebdav()
+ .assertThat().doesNotExistInRepo();
+
+ STEP("7. Verify U2 can't update document2 using WebDAV");
+ webDavProtocol.authenticateUser(testUser2)
+ .usingResource(testFile1).update("file2 content")
+ .assertThat().hasStatus(404);
+ }
+
+ /**
+ * Scenario 57
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates document1 in a public site using FTP
+ * 3. U2 is added to that public site with manager role using REST
+ * 4. U1 adds comment to document1 using REST
+ * 5. U2 gets document1 comments using REST
+ * 6. U1 renames document1 using CMIS
+ * 7. U2 deletes comment using REST
+ * 8. Verify U1 cannot get comment using REST
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
+ description = "Check that user can't get a comment that is deleted by another user.")
+ public void getCommentAfterItIsDeleted() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates document1 in a public site using FTP");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("3. U2 is added to that public site with manager role using REST");
+ testUser2.setUserRole(UserRole.SiteManager);
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(publicSite).addPerson(testUser2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. U1 adds comment to document1 using REST");
+ RestCommentModel user1Comment = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile1).addComment("user1 comment");
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. U2 gets document1 comments using REST");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).getNodeComments()
+ .assertThat().entriesListContains("content", "user1 comment");
+
+ STEP("6. U1 renames document1 using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).rename("new" + testFile1.getName())
+ .assertThat().existsInRepo()
+ .assertThat().contentPropertyHasValue("cmis:name", "new" + testFile1.getName())
+ .usingResource(testFile1).assertThat().doesNotExistInRepo();
+
+ STEP("7. U2 deletes comment using REST");
+ restAPI.withCoreAPI().usingResource(testFile1).deleteComment(user1Comment);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("8. Verify U1 cannot get comment using REST");
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile1).getNodeComments()
+ .assertThat().entriesListIsEmpty();
+ }
+
+ /**
+ * Scenario 59
+ * 1. Using CMIS create one test user: u1
+ * 2. U1 creates a public site using CMIS
+ * 3. Admin creates a folder with a document (doc1.txt) in the public site using WebDAV
+ * 4. Admin renames document1 (doc1-edited.txt) using WebDAV
+ * 5. U1 tries to move doc1.txt to another location using IMAP
+ * 6. Verify that document is not moved (catch Exceptions)
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL }, expectedExceptions = MessagingException.class)
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is not able to move a renamed file using its initial name.")
+ public void moveRenamedFileUsingInitialFilename() throws Exception
+ {
+ STEP("1. Using CMIS create one test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createIMAPSite();
+
+ STEP("3. Admin creates a folder with a document (doc1.txt) in the public site using WebDav");
+ parentFolder = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content");
+
+ webDavProtocol.authenticateUser(admin)
+ .usingSite(publicSite).createFolder(parentFolder)
+ .assertThat().existsInWebdav()
+ .usingResource(parentFolder).createFile(testFile1)
+ .assertThat().existsInWebdav();
+
+ STEP("4. Admin renames document1 (doc1-edited.txt) using WebDAV");
+ FileModel oldFile = new FileModel(testFile1);
+ webDavProtocol.authenticateUser(admin)
+ .usingResource(testFile1).rename("new" + testFile1.getName())
+ .assertThat().existsInRepo();
+
+ STEP("5. U1 tries to move doc1.txt to another location using IMAP");
+ FolderModel destination = new FolderModel(Utility.buildPath("Sites", publicSite.getId(), "documentLibrary"));
+ destination.setProtocolLocation(imapProtocol.authenticateUser(testUser1).usingSite(publicSite).getLastResourceWithoutPrefix());
+ imapProtocol.usingResource(oldFile).moveMessageTo(destination);
+ }
+
+ /**
+ * Scenario 61
+ * 1. Using CMIS create an user and a site.
+ * 2. Using FTP create two folders.
+ * 3. Using CMIS create documents in folder1: a-childDoc1, childDoc11, child21.
+ * 4. Using CMIS create documents in folder2: childDoc112, childDoc2, achild2.
+ * 5. Using IMAP client flag content 'childDoc112'.
+ * 6. Using IMAP find documents after search term 'child'.
+ * 7. Using IMAP find documents after search term '.*child2.*'.
+ * 8. Using IMAP find documents after search term 'childa'. No results should be displayed.
+ * 9. Using IMAP find documents after search term 'child*2'.
+ * 10. Using IMAP verify that 'childDoc112' is flagged.
+ *
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Find files and flag files.")
+ public void findFilesAndFlagFiles() throws Exception
+ {
+ STEP("1. Using CMIS create an user and a site.");
+ UserModel testUser = dataUser.createRandomTestUser();
+ SiteModel testSitePublic = dataSite.usingUser(testUser).createIMAPSite();
+
+ STEP("2. Using FTP create two folders.");
+ FolderModel folder1 = FolderModel.getRandomFolderModel();
+ FolderModel folder2 = FolderModel.getRandomFolderModel();
+
+ ftpProtocol.authenticateUser(testUser).usingSite(testSitePublic).createFolder(folder1).and().createFolder(folder2);
+
+ STEP("3. Using CMIS create documents in folder1: a-childDoc1, childDoc11, child21.");
+
+ FileModel file11 = dataContent.usingUser(testUser).usingSite(testSitePublic).usingResource(folder1)
+ .createContent(new FileModel("a-childDoc1", FileType.TEXT_PLAIN, "content"));
+ FileModel file12 = dataContent.usingUser(testUser).usingSite(testSitePublic).usingResource(folder1)
+ .createContent(new FileModel("childDoc11", FileType.TEXT_PLAIN, "content"));
+ FileModel file13 = dataContent.usingUser(testUser).usingSite(testSitePublic).usingResource(folder1)
+ .createContent(new FileModel("child21", FileType.TEXT_PLAIN, "content"));
+
+ STEP("4. Using CMIS create documents in folder2: childDoc112, childDoc2, achild2.");
+
+ FileModel file21 = dataContent.usingUser(testUser).usingSite(testSitePublic).usingResource(folder2)
+ .createContent(new FileModel("childDoc112", FileType.TEXT_PLAIN, "content"));
+ FileModel file22 = dataContent.usingUser(testUser).usingSite(testSitePublic).usingResource(folder2)
+ .createContent(new FileModel("childDoc2", FileType.TEXT_PLAIN, "content"));
+ FileModel file23 = dataContent.usingUser(testUser).usingSite(testSitePublic).usingResource(folder2)
+ .createContent(new FileModel("achild2", FileType.TEXT_PLAIN, "content"));
+
+ STEP("5. Using IMAP client flag content 'childDoc112'.");
+ imapProtocol.authenticateUser(testUser).usingResource(file21).withMessage().setFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN).updateFlags();
+
+ STEP("6. Using IMAP find documents after search term 'child'.");
+ imapProtocol.usingResource(folder1).searchSubjectFor("child")
+ .assertThat().resultsContainMessage(file11,file12,file13)
+ .usingResource(folder2).searchSubjectFor("child")
+ .assertThat().resultsContainMessage(file21,file22,file23);
+
+ STEP("7. Using IMAP find documents after search term '.*child2.*'.");
+ imapProtocol.usingResource(folder2).searchSubjectWithWildcardsFor(".*child2.*")
+ .assertThat().resultsContainMessage(file23)
+ .assertThat().resultsDoNotContainMessage(file21,file22);
+
+ STEP("8. Using IMAP find documents after search term 'childa'. No results should be displayed.");
+ imapProtocol.usingResource(folder1).searchSubjectFor("childa")
+ .assertThat().resultsDoNotContainMessage(file11,file12,file13)
+ .usingResource(folder2).searchSubjectFor("childa")
+ .assertThat().resultsDoNotContainMessage(file21,file22,file23);
+
+ STEP("9. Using IMAP find documents after search term 'child*2'.");
+ imapProtocol.usingResource(folder1).searchSubjectWithWildcardsFor("child.*2.*")
+ .assertThat().resultsContainMessage(file13)
+ .assertThat().resultsDoNotContainMessage(file11,file12)
+ .usingResource(folder2).searchSubjectWithWildcardsFor("child.*2.*")
+ .assertThat().resultsContainMessage(file21,file22)
+ .assertThat().resultsDoNotContainMessage(file23);
+
+ STEP("10. Using IMAP verify that 'childDoc112' is flagged.");
+ imapProtocol.usingResource(file21)
+ .assertThat().messageContainsFlags(Flags.Flag.ANSWERED, Flags.Flag.SEEN);
+ }
+
+ /**
+ * Scenario 62
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using WebDAV: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. U1 adds items to task using REST
+ * 7. U1 removes items from task using REST
+ * 8. userToAssign gets the list of the updated items using REST
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assigner user is able to add and remove items from task.")
+ public void assignerIsAbleToAddAndRemoveItemsFromTask() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ UserModel userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using WebDAV: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite)
+ .createFile(testFile1)
+ .assertThat().webDavWrapper()
+ .assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ processTasks = restAPI.authenticateUser(userToAssign).withWorkflowAPI()
+ .usingProcess(processModel)
+ .getProcessTasks();
+ restAPI.withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .addTaskItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ processTasks = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel)
+ .getProcessTasks();
+ processTasks.assertThat().entriesListContains("assignee", userToAssign.getUsername())
+ .and().entriesListContains("state", "claimed")
+ .and().paginationField("count").is("1");
+
+ STEP("6. U1 adds items to task using REST");
+ testFile2 = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.HTML);
+ FileModel testFile3 = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.PDF);
+ taskItems = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .addTaskItems(testFile2, testFile3);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("7. U1 removes items from task using REST");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .deleteTaskItem(taskItems.getEntries().get(0).onModel());
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("8. userToAssign gets the list of the updated items using REST");
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .getTaskItems()
+ .assertThat().entriesListContains("name", testFile1.getName())
+ .assertThat().entriesListContains("name", testFile3.getName())
+ .and().paginationField("count").is("2");
+ }
+
+ /**
+ * Scenario 63
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDAV: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. userToAssign adds items to task using REST
+ * 7. userToAssign removes items from task using REST
+ * 8. u1 gets the list of the updated items using REST
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assignee user is to add and remove items from task.")
+ public void assigneeIsAbleToAddAndRemoveItemsFromTask() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ UserModel userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDAV: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite)
+ .createFile(testFile1)
+ .assertThat().existsInWebdav()
+ .assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ processTasks = restAPI.authenticateUser(userToAssign).withWorkflowAPI()
+ .usingProcess(processModel)
+ .getProcessTasks();
+ restAPI.withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .addTaskItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ processTasks = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel)
+ .getProcessTasks();
+ processTasks.assertThat().entriesListContains("assignee", userToAssign.getUsername())
+ .and().entriesListContains("state", "claimed")
+ .and().paginationField("count").is("1");
+
+ STEP("6. userToAssign adds items to task using REST");
+ testFile2 = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.HTML);
+ FileModel testFile3 = dataContent.usingSite(publicSite).createContent(CMISUtil.DocumentType.PDF);
+
+ taskItems = restAPI.withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .addTaskItems(testFile2, testFile3);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("7. userToAssign removes items from task using REST");
+ restAPI.withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .deleteTaskItem(taskItems.getEntries().get(1).onModel());
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("8. U1 gets the list of the updated items using REST");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .getTaskItems()
+ .assertThat().entriesListContains("name", testFile2.getName())
+ .assertThat().entriesListContains("name", testFile1.getName())
+ .and().paginationField("count").is("2");
+ }
+
+ /**
+ * Scenario 66
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDavProtocol: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. Status is changed by userToAssign using REST
+ * 7. U1 gets the modified values from the task using REST
+ * 8. userToAssign marks the task as 'Resolved' using REST
+ * 9. U1 receives the task using REST
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assignee user is able to update task.")
+ public void assigneeIsAbleToUpdateTask() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDavProtocol: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ taskModel = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks()
+ .getTaskModelByAssignee(userToAssign)
+ .assertThat().field("assignee").is(userToAssign.getUsername());
+
+ STEP("6. Status is changed by userToAssign using REST");
+ restTaskModel = restAPI.authenticateUser(userToAssign).withParams("select=state").withWorkflowAPI().usingTask(taskModel)
+ .updateTask("claimed");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ restTaskModel.assertThat().field("id").is(taskModel.getId())
+ .and().field("state").is("claimed");
+
+ STEP("7. U1 gets the modified values from the task using REST");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingTask(restTaskModel).getTask()
+ .assertThat().field("id").is(taskModel.getId())
+ .and().field("state").is("claimed");
+
+ STEP("8. userToAssign marks the task as 'Resolved' using REST");
+ restTaskModel = restAPI.authenticateUser(userToAssign).withParams("select=state").withWorkflowAPI().usingTask(taskModel)
+ .updateTask("completed");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ restTaskModel.assertThat().field("id").is(taskModel.getId())
+ .and().field("state").is("completed")
+ .and().field("assignee").is(userToAssign.getUsername());
+
+ STEP("9. U1 receives the task using REST");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingTask(restTaskModel).getTask()
+ .assertThat().field("state").is("completed");
+ }
+
+ /**
+ * Scenario 67
+ * 1. Using CMIS create two test users: U1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDavProtocol: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. Status is changed by U1 using REST
+ * 7. userToAssign gets the modified values from the task using REST
+ * 8. userToAssign marks the task as 'Resolved' using REST
+ * 9. U1 receives the task using REST
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assigner user is able to update task.")
+ public void assignerIsAbleToUpdateTask() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDavProtocol: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ taskModel = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks().getEntryByIndex(0)
+ .assertThat().field("assignee").is(userToAssign.getUsername());
+
+ STEP("6. Status is changed by U1 using REST");
+ JsonObject inputJson = JsonBodyGenerator.defineJSON().add("state", "delegated").add("assignee", userToAssign.getUsername()).build();
+ restTaskModel = restAPI.authenticateUser(testUser1).withParams("select=state,assignee").withWorkflowAPI().usingTask(taskModel)
+ .updateTask(inputJson);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ restTaskModel.assertThat().field("id").is(taskModel.getId())
+ .and().field("state").is("delegated")
+ .and().field("owner").is(testUser1.getUsername())
+ .and().field("assignee").is(userToAssign.getUsername());
+
+ STEP("7. userToAssign gets the modified values from the task using REST");
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks().getTaskModelByAssignee(userToAssign)
+ .assertThat().field("id").is(taskModel.getId())
+ .and().field("state").is("delegated");
+
+ STEP("8. userToAssign marks the task as 'Resolved' using REST");
+ restTaskModel = restAPI.withParams("select=state").withWorkflowAPI().usingTask(taskModel).updateTask("resolved");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ restTaskModel.assertThat().field("id").is(taskModel.getId())
+ .and().field("state").is("resolved");
+
+ STEP("9. U1 receives the task using REST");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingProcess(processModel).getProcessTasks().getEntryByIndex(0)
+ .assertThat().field("state").is("resolved")
+ .assertThat().field("id").is(taskModel.getId())
+ .assertThat().field("assignee").is(testUser1.getUsername());
+ }
+
+ /**
+ * Scenario 68
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDavProtocol: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. U1 cancels workflow using REST
+ * 7. Verify task is no longer present for userToAssign
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assigner user is able to cancel an workflow.")
+ public void assignerIsAbleToCancelWorkflow() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDavProtocol: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI().addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ restAPI.withWorkflowAPI().getProcesses()
+// due changing to java 11 the id changed
+// .assertThat().entriesListContains("processDefinitionId", WorkflowService.WorkflowType.NewTask.getId())
+ .assertThat().entriesListContains("startActivityId", "start")
+ .and().paginationField("count").is("1");
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks()
+ .getTaskModelByAssignee(userToAssign)
+ .assertThat().field("assignee").is(userToAssign.getUsername());
+
+ STEP("6. U1 cancels workflow using REST");
+ Assert.assertTrue(dataWorkflow.usingUser(testUser1).cancelProcess(processModel), "User is able to cancel the workflow");
+
+ restAPI.withWorkflowAPI().getProcesses().assertThat()
+ .entriesListDoesNotContain("id", processModel.getId())
+ .and().paginationField("count").is("0");
+
+ STEP("7. Verify task is no longer present for userToAssign: MyTasks");
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().getProcesses().assertThat()
+ .entriesListDoesNotContain("id", processModel.getId());
+ }
+
+ /**
+ * Scenario 69
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDavProtocol: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. userToAssign is not able to cancel workflow using REST
+ * 7. Verify U1 still has the workflow
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assignee user is able to cancel an workflow.")
+ public void assigneeIsNotAbleToCancelWorkflow() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDavProtocol: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI().addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ restAPI.withWorkflowAPI().getProcesses()
+ .assertThat().entriesListContains("startActivityId", "start")
+ .and().paginationField("count").is("1");
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks()
+ .getTaskModelByAssignee(userToAssign)
+ .assertThat().field("assignee").is(userToAssign.getUsername());
+
+ STEP("6. userToAssign is not able to cancel workflow using REST");
+ Assert.assertFalse(dataWorkflow.usingUser(userToAssign).cancelProcess(processModel), "User is unable to cancel workflow.");
+
+ restAPI.withWorkflowAPI().getProcesses().assertThat()
+ .entriesListContains("id", processModel.getId())
+ .and().paginationField("count").is("1");
+
+ STEP("7. Verify U1 still has the workflow");
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().getProcesses().assertThat()
+ .entriesListContains("id", processModel.getId())
+ .and().paginationField("count").is("1");
+ }
+
+ /**
+ * Scenario 70
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDavProtocol: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. U1 renames the document using webDAV
+ * 7. Verify renamed document with users: U1 and userToAssign using RestAPI
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assigner user is able to rename items from a task.")
+ public void assignerIsAbleToRenameItemsFromTask() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDavProtocol: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ taskModel = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks()
+ .getTaskModelByAssignee(userToAssign)
+ .assertThat().field("assignee").is(userToAssign.getUsername());
+
+ STEP("6. U1 renames the document using webDAV");
+ FileModel originalFileModel = new FileModel(testFile1);
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite)
+ .usingResource(testFile1).and().assertThat().existsInRepo()
+ .when().rename(testFile1.getName() + "-edit").assertThat().existsInRepo()
+ .and().assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_CREATED)
+ .then().usingSite(publicSite).usingResource(originalFileModel).assertThat().doesNotExistInRepo();
+
+ STEP("7. Verify renamed document with users: U1 and userToAssign using RestAPI");
+ processTasks = restAPI.authenticateUser(testUser1).withWorkflowAPI().usingProcess(processModel)
+ .getProcessTasks();
+ restAPI.withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .getTaskItems()
+ .assertThat().entriesListContains("name", testFile1.getName()+ "-edit")
+ .assertThat().entriesListDoesNotContain("name", originalFileModel.getName())
+ .and().paginationField("count").is("1");
+
+ processTasks = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel)
+ .getProcessTasks();
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign))
+ .getTaskItems()
+ .assertThat().entriesListContains("name", testFile1.getName()+ "-edit")
+ .assertThat().entriesListDoesNotContain("name", originalFileModel.getName())
+ .and().paginationField("count").is("1");
+ }
+
+ /**
+ * Scenario 71
+ * 1. Using CMIS create two test users: u1 and userToAssign
+ * 2. U1 creates a public site using CMIS: publicSite
+ * 3. U1 creates a document in public site using webDavProtocol: documentTest
+ * 4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST
+ * 5. Verify that userToAssign receives the task using REST
+ * 6. U1 deletes the document using webDAV
+ * 7. Verify no documents are present with users: U1 and userToAssign using RestAPI
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assigner user is able to delete items from a task.")
+ public void assignerIsAbleToDeleteItemsFromTask() throws Exception
+ {
+ STEP("1. Using CMIS create two test users: u1 and userToAssign");
+ testUser1 = dataUser.createRandomTestUser();
+ userToAssign = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public site using CMIS: publicSite");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 creates a document in public site using webDavProtocol: documentTest");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U1 creates a new task with the documents created above and assigns the task to userToAssign using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", userToAssign, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Verify that userToAssign receives the task using REST");
+ taskModel = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks()
+ .getTaskModelByAssignee(userToAssign)
+ .assertThat().field("assignee").is(userToAssign.getUsername());
+
+ STEP("6. U1 deletes the document using webDAV");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite)
+ .usingResource(testFile1).delete()
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_OK)
+ .and().assertThat().doesNotExistInRepo()
+ .and().assertThat().doesNotExistInWebdav()
+ .and().assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_NOT_FOUND);
+
+ STEP("7. Verify no documents are present with users: U1 and userToAssign using RestAPI");
+ processTasks = restAPI.authenticateUser(testUser1).withWorkflowAPI().usingProcess(processModel)
+ .getProcessTasks();
+ restAPI.withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign)).getTaskItems().assertThat()
+ .entriesListDoesNotContain("name", testFile1.getName()).and()
+ .paginationField("count").is("0");
+
+ processTasks = restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingProcess(processModel).getProcessTasks();
+ restAPI.authenticateUser(userToAssign).withWorkflowAPI().usingTask(processTasks.getTaskModelByAssignee(userToAssign)).getTaskItems().assertThat()
+ .entriesListDoesNotContain("name", testFile1.getName()).and()
+ .paginationField("count").is("0");
+ }
+
+
+ /**
+ * Scenario 72
+ * 1. Using CMIS create 1 test user: u1
+ * 2. U1 creates folder1 in a public site using IMAP
+ * 3. U1 creates file with special symbols in its name using FTP inside the public site
+ * 4. U1 adds some special characters in document content using CMIS
+ * 5. U1 renames document to a different name using special chars using FTP
+ * 6. U1 copy document to the folder created above using IMAP
+ * 7. U1 deletes document from initial location using CMIS
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user is able to create, rename, update content, delete a file with special symbols in its name.")
+ public void userIsAbleToDoCRUDActionsOnFileWithSpecialName() throws Exception
+ {
+ STEP("1. Using CMIS create 1 test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates folder1 in a public site using IMAP");
+ publicSite = dataSite.usingUser(testUser1).createIMAPSite();
+ parentFolder = FolderModel.getRandomFolderModel();
+
+ imapProtocol.authenticateUser(testUser1)
+ .usingSite(publicSite).createFolder(parentFolder)
+ .assertThat().existsInImap().and()
+ .assertThat().existsInRepo();
+
+ STEP("3. U1 creates file with special symbols in its name using FTP inside the public site");
+ String fileName = RandomData.getRandomAlphanumeric();
+ testFile1 = new FileModel(fileName + "\ufeff\u6768\u6728\u91d1.doc");
+ ftpProtocol.authenticateUser(testUser1)
+ .then().usingSite(publicSite)
+ .createFile(testFile1).and().assertThat().existsInRepo()
+ .and().assertThat().existsInFtp();
+
+ STEP("4. U1 adds some special characters in document content using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).update("!@#$%^&()-_+={}[].,")
+ .assertThat().contentIs("!@#$%^&()-_+={}[].,");
+
+ STEP("5. U1 renames document to a different name using special chars using FTP");
+ ftpProtocol.usingResource(testFile1).rename(fileName + "!@#$%^&()-_+={}[].,")
+ .assertThat().existsInRepo();
+
+ testFile2 = new FileModel(testFile1);
+ STEP("6. U1 copy document to the folder created above using IMAP");
+ imapProtocol.authenticateUser(testUser1).usingSite(publicSite)
+ .usingResource(testFile1)
+ .assertThat().existsInRepo()
+ .assertThat().existsInImap()
+ .copyMessageTo(parentFolder)
+ .assertThat().containsMessages(testFile1);
+
+ STEP("7. U1 deletes document from initial location using CMIS");
+ cmisAPI.usingResource(testFile2).delete().assertThat().doesNotExistInRepo()
+ .usingResource(parentFolder).assertThat().hasFiles(testFile1);
+ }
+
+ /**
+ * Scenario 75
+ * 1. Using CMIS create 3 test users: u1, u2 and u3
+ * 2. U1 creates document1 in a public site using WebDAV
+ * 3. U1 adds U3 to his site as Site manager using REST
+ * 4. Check that U2 is not able to update document using FTP.
+ * 5. Check that U3 is able to update document using WebDAV.
+ * 6. U1 changes site visibility to moderated using REST
+ * 7. Check that U2 is not able to update document using FTP.
+ * 8. Check that U3 is able to update document WebDAV.
+ * 9. U1 changes site visibility to private using REST
+ * 10. Check that U2 is not able to update document using FTP.
+ * 11. Check that U3 is able to update document WebDAV.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify users ability to update files when site visibility is changed.")
+ public void updateFileByRegularUserAndSiteMemberWhenSiteVisibilityIsChanged() throws Exception
+ {
+ STEP("1. Using CMIS create 3 test users: u1, u2 and u3");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+ UserModel testUser3 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates document1 in a public site using WebDAV");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingSite(publicSite).createFile(testFile1)
+ .assertThat().existsInRepo();
+
+ STEP("3. U1 adds U3 to his site as Site manager using REST");
+ testUser3.setUserRole(UserRole.SiteManager);
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(publicSite).addPerson(testUser3);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. Check that U2 is able to update document using FTP.");
+ ftpProtocol.authenticateUser(testUser2).usingResource(testFile1).update("u2 update when site visibility is public")
+ .assertThat().contentIs("file1 content");
+
+ STEP("5. Check that U3 is able to update document using WebDav.");
+ webDavProtocol.authenticateUser(testUser3).usingResource(testFile1).update("u3 update when site visibility is public")
+ .assertThat().contentIs("u3 update when site visibility is public");
+
+ STEP("6. U1 changes site visibility to moderated using REST");
+ dataSite.usingUser(testUser1).updateSiteVisibility(publicSite, Visibility.MODERATED);
+
+ STEP("7. Check that U2 is not able to update document using FTP.");
+ ftpProtocol.authenticateUser(testUser2).usingResource(testFile1).update("u2 update when site visibility is moderated")
+ .assertThat().hasReplyCode(FTPReply.ACTION_ABORTED);
+
+ STEP("8. Check that U3 is able to update document WebDAV.");
+ webDavProtocol.authenticateUser(testUser3).usingResource(testFile1).update("u3 update when site visibility is moderated")
+ .assertThat().contentIs("u3 update when site visibility is moderated");
+
+ STEP("9. U1 changes site visibility to private using REST");
+ dataSite.usingUser(testUser1).updateSiteVisibility(publicSite, Visibility.PRIVATE);
+
+ STEP("10. Check that U2 is not able to update document using FTP.");
+ ftpProtocol.authenticateUser(testUser2).usingResource(testFile1).update("u2 update when site visibility is private")
+ .assertThat().hasReplyCode(FTPReply.ACTION_ABORTED);
+
+ STEP("11. Check that U3 is able to update document WebDAV.");
+ webDavProtocol.authenticateUser(testUser3).usingResource(testFile1).update("u3 update when site visibility is private")
+ .assertThat().contentIs("u3 update when site visibility is private");
+ }
+
+ /**
+ * Scenario 89
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates document1 in a public site using FTP
+ * 3. U1 creates a New Task with the document created above and assigns it to U2 using REST
+ * 4. U2 updates the task as resolved using REST
+ * 5. U1 deletes the task process using REST. Assert that process is deleted successfully among with its tasks.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify initiator is able to delete a process after its task is updated by assignee as resolved.")
+ public void deleteWorkflowByInitiator() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates document1 in a public site using FTP");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("3. U1 creates a New Task with the document created above and assigns it to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. U2 updates the task as Done using REST");
+ processTasks = restAPI.authenticateUser(testUser2).withWorkflowAPI().usingProcess(processModel).getProcessTasks();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ RestTaskModel processTask = processTasks.getTaskModelByAssignee(testUser2);
+
+ restAPI.withParams("select=state").withWorkflowAPI().usingTask(processTask).updateTask("resolved");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ STEP("5. U1 deletes the task process using REST. Assert that process is deleted successfully among with its tasks.");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingProcess(processModel).deleteProcess();
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+ restAPI.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", processModel.getId());
+ restAPI.withWorkflowAPI().getTasks().assertThat().entriesListDoesNotContain("id", processTask.getId());
+ }
+
+ /**
+ * Scenario 90
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates document1 in a public site using WebDAV
+ * 3. U1 creates a New Task with the document created above and assigns it to U2 using REST
+ * 4. U2 updates the task as resolved using REST
+ * 5. U1 updates the task as completed using REST
+ * 6. U2 deletes the task process using REST. Assert that process is not deleted.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify assignee is not able to delete a process after its task is completed.")
+ public void deleteWorkflowByAssignee() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates document1 in a public site using WebDAV");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("3. U1 creates a New Task with the document created above and assigns it to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. U2 updates the task as resolved using REST");
+ processTasks = restAPI.authenticateUser(testUser2).withWorkflowAPI().usingProcess(processModel).getProcessTasks();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ RestTaskModel processTask = processTasks.getTaskModelByAssignee(testUser2);
+
+ restAPI.withParams("select=state").withWorkflowAPI().usingTask(processTask).updateTask("resolved");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ STEP("5. U1 updates the task as completed using REST");
+ restAPI.authenticateUser(testUser1).withParams("select=state").withWorkflowAPI().usingTask(processTask).updateTask("completed");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ STEP("6. U2 deletes the task process using REST. Assert that process is not deleted. ");
+ restAPI.authenticateUser(testUser2).withWorkflowAPI().usingProcess(processModel).deleteProcess();
+ restAPI.assertStatusCodeIs(HttpStatus.FORBIDDEN)
+ .assertLastError().containsSummary(String.format(RestErrorModel.ACCESS_INFORMATION_NOT_ALLOWED, processModel.getId()));
+ }
+
+ /**
+ * Scenario 91
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates document1 in a public site using CMIS
+ * 3. U1 creates a New Task with the document created above and assigns it to U2 using REST
+ * 4. U1 deletes the task process using REST. Assert that process is deleted.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW }, executionType = ExecutionType.REGRESSION,
+ description = "Verify initiator is able to delete a process even if its task is not completed.")
+ public void deleteWorkflowWithoutCompletingIt() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates document1 in a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ cmisAPI.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("3. U1 creates a New Task with the document created above and assigns it to U2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. U1 deletes the task process using REST. Assert that process is deleted.");
+ restAPI.withWorkflowAPI().usingProcess(processModel).deleteProcess();
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+ restAPI.withWorkflowAPI().getProcesses().assertThat().entriesListDoesNotContain("id", processModel.getId());
+ }
+
+ /**
+ * Scenario 94
+ * 1. Using CMIS create one test user: u1
+ * 2. Using FTP create file in unauthorized folder (Data Dictionary)
+ * 3. Verify that document is not created
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION,
+ description = "Verify that document is not created in unauthorized folder (Data Dictonary)")
+ public void createUserMakeUnathorizedAction() throws Exception
+ {
+ STEP("1. Using CMIS creates one test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. Using FTP create file in unauthorized folder (Data Dictionary). 3. Verify that document is not created");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+
+ ftpProtocol.authenticateUser(testUser1)
+ .changeWorkingDirectory(ftpProtocol.getDataDictionaryPath())
+ .assertThat().currentFolderIs(ftpProtocol.getDataDictionaryPath())
+ .createFile(testFile1).assertThat().doesNotExistInFtp();
+ }
+
+ /**
+ * Scenario 95
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates 2 documents in User Homes using CMIS
+ * 3. U1 verifies the list of available process definitions using REST
+ * 4. U1 creates a workflow of type "activitiAdhoc" with the documents created above and assign it to u2 using REST
+ * 5. U1 adds a new process variable using REST
+ * 6. U2 gets the process variables using REST
+ * 7. U2 closes the task using REST
+ * 8. Verify that user2 doesn't have access to the documents attached to the task using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW}, executionType = ExecutionType.REGRESSION,
+ description = "Verify assignee user is able to get a process variable added by another user.")
+ public void createWorkflowProcessWithNewProcessVariable() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates 2 documents in User Homes using CMIS");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file2 content");
+ cmisAPI.authenticateUser(testUser1).usingUserHome()
+ .createFile(testFile1).assertThat().existsInRepo()
+ .createFile(testFile2).assertThat().existsInRepo();
+
+ STEP("3. U1 verifies the list of available process definitions using REST");
+ RestProcessDefinitionModelsCollection procDefinitions = restAPI.authenticateUser(testUser1).withWorkflowAPI().getAllProcessDefinitions();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ procDefinitions.assertThat().entriesListContains("key", "activitiAdhoc");
+
+ STEP("4. U1 creates a workflow of type 'activitiAdhoc' with the documents created above and assign it to u2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiAdhoc", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. U1 adds a new process variable using REST");
+ RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
+
+ RestProcessVariableModel processVariable = restAPI.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ processVariable.assertThat().field("name").is(variableModel.getName())
+ .and().field("type").is(variableModel.getType())
+ .and().field("value").is(variableModel.getValue());
+
+ STEP("6. U2 gets the process variables using REST");
+ RestProcessVariableCollection processVariables = restAPI.authenticateUser(testUser2).withWorkflowAPI().usingProcess(processModel).getProcessVariables();
+ processVariables.getProcessVariableByName(processVariable.getName())
+ .assertThat().field("type").is(processVariable.getType())
+ .assertThat().field("value").is(processVariable.getValue());
+
+ processVariables.getProcessVariableByName("bpm_assignee")
+ .assertThat().field("type").is("cm:person")
+ .assertThat().field("value").is(testUser2.getUsername());
+
+ processVariables.getProcessVariableByName("bpm_priority")
+ .assertThat().field("type").is("d:int")
+ .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel());
+
+ processVariables.getProcessVariableByName("bpm_sendEMailNotifications")
+ .assertThat().field("type").is("d:boolean")
+ .assertThat().field("value").is(false);
+
+ processVariables.getProcessVariableByName("initiator")
+ .assertThat().field("type").is("d:noderef")
+ .assertThat().field("value").is(testUser1.getUsername());
+
+ processVariables.getProcessVariableByName("bpm_percentComplete")
+ .assertThat().field("type").is("d:int")
+ .assertThat().field("value").is(0);
+
+ STEP("7. U2 closes the task using REST");
+ RestTaskModel processTask = restAPI.withWorkflowAPI().usingProcess(processModel).getProcessTasks().getTaskModelByAssignee(testUser2);
+ restAPI.withParams("select=state").withWorkflowAPI().usingTask(processTask).updateTask("completed");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ STEP("8. Verify that user2 doesn't have access to the documents attached to the task using FTP");
+ ftpProtocol.authenticateUser(testUser2)
+ .usingResource(testFile1).assertThat().hasReplyCode(FTPReply.FILE_UNAVAILABLE).and().assertThat().doesNotExistInFtp()
+ .usingResource(testFile2).assertThat().hasReplyCode(FTPReply.FILE_UNAVAILABLE).and().assertThat().doesNotExistInFtp();
+ }
+
+ /**
+ * Scenario 96
+ * 1. Using CMIS create 2 test users: u1 and u2.
+ * 2. U1 creates 2 documents in User Homes using CMIS
+ * 3. U1 verifies the list of available process definitions using REST
+ * 4. U1 creates a workflow of type 'activitiReview' with the documents created above and assign it to u2 using REST
+ * 5. U1 adds a new process variable using REST
+ * 6. U2 gets the process variables using REST
+ * 7. U2 closes the task using REST
+ * 8. U1 deletes the new added process variable
+ * 9. U1 starts new 'activitiReview' process. Verify the process doesn't have the process variable added above.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WORKFLOW}, executionType = ExecutionType.REGRESSION,
+ description = "Verify process variable is process specific, not process definition.")
+ public void createWorkflowProcessAndDeleteProcessVariable() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2.");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates 2 documents in User Homes using CMIS");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file2 content");
+ cmisAPI.authenticateUser(testUser1).usingUserHome()
+ .createFile(testFile1).assertThat().existsInRepo()
+ .createFile(testFile2).assertThat().existsInRepo();
+
+ STEP("3. U1 verifies the list of available process definitions using REST");
+ RestProcessDefinitionModelsCollection procDefinitions = restAPI.authenticateUser(testUser1).withWorkflowAPI().getAllProcessDefinitions();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ procDefinitions.assertThat().entriesListContains("key", "activitiReview");
+
+
+ STEP("4. U1 creates a workflow of type 'activitiParallelGroupReview' with the documents created above and assign it to u2 using REST");
+ processModel = restAPI.authenticateUser(testUser1).withWorkflowAPI()
+ .addProcess("activitiReview", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withWorkflowAPI().usingProcess(processModel).addProcessItem(testFile2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. U1 adds a new process variable using REST");
+ RestProcessVariableModel variableModel = RestProcessVariableModel.getRandomProcessVariableModel("d:text");
+
+ RestProcessVariableModel processVariable = restAPI.withWorkflowAPI().usingProcess(processModel).addProcessVariable(variableModel);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ processVariable.assertThat().field("name").is(variableModel.getName())
+ .and().field("type").is(variableModel.getType())
+ .and().field("value").is(variableModel.getValue());
+
+ STEP("6. U2 gets the process variables using REST");
+ RestProcessVariableCollection processVariables = restAPI.authenticateUser(testUser2).withWorkflowAPI().usingProcess(processModel).getProcessVariables();
+ processVariables.getProcessVariableByName(processVariable.getName())
+ .assertThat().field("type").is(processVariable.getType())
+ .assertThat().field("value").is(processVariable.getValue());
+
+ processVariables.getProcessVariableByName("bpm_assignee")
+ .assertThat().field("type").is("cm:person")
+ .assertThat().field("value").is(testUser2.getUsername());
+
+ processVariables.getProcessVariableByName("bpm_priority")
+ .assertThat().field("type").is("d:int")
+ .assertThat().field("value").is(CMISUtil.Priority.Normal.getLevel());
+
+ processVariables.getProcessVariableByName("bpm_sendEMailNotifications")
+ .assertThat().field("type").is("d:boolean")
+ .assertThat().field("value").is(false);
+
+ processVariables.getProcessVariableByName("initiator")
+ .assertThat().field("type").is("d:noderef")
+ .assertThat().field("value").is(testUser1.getUsername());
+
+ processVariables.getProcessVariableByName("wf_reviewOutcome")
+ .assertThat().field("type").is("d:text")
+ .assertThat().field("value").is("Reject");
+
+ STEP("7. U2 closes the task using REST");
+ RestTaskModel processTask = restAPI.withWorkflowAPI().usingProcess(processModel).getProcessTasks().getTaskModelByAssignee(testUser2);
+ restAPI.withParams("select=state").withWorkflowAPI().usingTask(processTask).updateTask("completed");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ STEP("8. U1 deletes the new added process variable");
+ restAPI.authenticateUser(testUser1).withWorkflowAPI().usingProcess(processModel).deleteProcessVariable(processVariable);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("9. U1 starts new 'activitiReview' process. Verify the process doesn't have the process variable added above.");
+ processModel = restAPI.withWorkflowAPI().addProcess("activitiReview", testUser2, false, CMISUtil.Priority.Normal);
+ restAPI.withWorkflowAPI().usingProcess(processModel).getProcessVariables().assertThat()
+ .entriesListDoesNotContain("name", processVariable.getName());
+ }
+
+ /**
+ * Scenario 97
+ * 1. Using CMIS create 2 public sites: s1, s2.
+ * 2. Using CMIS create test users: u1 and u2.
+ * 3. Using RestAPI add u1 to s1 and s2, u2 to s2.
+ * 4. Using RestAPI add all sites to favorites for every user.
+ * 5. Using RestAPI get preferences and check that favorited sites are listed.
+ * 6. Using RestAPI, u1 removes site1 from favorites, u2 removes site2 from favorites.
+ * 7. Using RestAPI get preferences and check that favorited sites are listed. Removed sites are not listed.
+ * 8. Using FTP U1 creates file1 in s1 document library and adds it to favorites using RestAPI. Same for u2 and s2
+ * 9. Using RestAPI U1 and U2 get preferences. Files added to favorites are listed.
+ * 10. Using WebDAV rename file1 and file2.
+ * 11. Using RestAPI U1 and U2 get preferences. Files renamed are listed.
+ * 12. Using FTP delete files.
+ * 13. Using CMIS delete site1.
+ * 14. Using RestAPI get preferences. Files and sites deleted are not listed anymore as favorites.
+ */
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can get preferences of sites and documents which were updated or deleted")
+ @Bug(id = "ACE-5769")
+ public void getUserPreferencesForSitesAndFiles() throws Exception
+ {
+ RestPreferenceModelsCollection restPreferenceModelsCollection;
+
+ STEP("1. Using CMIS create 2 public sites: s1, s2.");
+ SiteModel testSitePublic1 = dataSite.usingUser(testUser1).createPublicRandomSite();
+ SiteModel testSitePublic2 = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("2. Using CMIS create test users: u1 and u2.");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("3. Using RestAPI add u1 to s1 and s2, u2 to s2.");
+ dataUser.addUserToSite(testUser1, testSitePublic1, UserRole.SiteManager);
+ dataUser.addUserToSite(testUser1, testSitePublic2, UserRole.SiteCollaborator);
+ dataUser.addUserToSite(testUser2, testSitePublic2, UserRole.SiteManager);
+
+ STEP("4. Using RestAPI add all sites to favorites for every user.");
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ restAPI.withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. Using RestAPI get preferences and check that favorited sites are listed.");
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("4");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("value", "true");
+
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("4");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("value", "true");
+
+ STEP("6. Using RestAPI, u1 removes site1 from favorites, u2 removes site2 from favorites.");
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().removeFavoriteSite(testSitePublic1);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().removeFavoriteSite(testSitePublic2);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("7. Using RestAPI get preferences and check that favorited sites are listed. Removed sites are not listed.");
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("3");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("value", "true");
+
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("3");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("value", "true");
+
+ STEP("8. Using FTP U1 creates file1 in s1 document library and adds it to favorites using RestAPI. Same for u2 and s2");
+ FileModel file1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ FileModel file2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic1).createFile(file1);
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().addFileToFavorites(file1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ ftpProtocol.authenticateUser(testUser2).usingSite(testSitePublic2).createFile(file2);
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(file2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("9. Using RestAPI U1 and U2 get preferences. Files added to favorites are listed.");
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("5");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", "org.alfresco.ext.documents.favourites.workspace://SpacesStore/" + file1.getNodeRef() +".createdAt")
+ .and().entriesListContains("value", "workspace://SpacesStore/" + file1.getNodeRef())
+ .and().entriesListContains("value", "true");
+
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("5");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", "org.alfresco.ext.documents.favourites.workspace://SpacesStore/" + file2.getNodeRef() +".createdAt")
+ .and().entriesListContains("value", "workspace://SpacesStore/" + file2.getNodeRef())
+ .and().entriesListContains("value", "true");
+
+ STEP("10. Using WebDAV rename file1 and file2.");
+ webDavProtocol.authenticateUser(testUser1).usingResource(file1).rename(file1.getName()+ "-updated-file1");
+ webDavProtocol.authenticateUser(testUser2).usingResource(file2).rename(file2.getName()+ "-updated-file2");
+
+ STEP("11. Using RestAPI U1 and U2 get preferences. Files renamed are listed.");
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("5");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", "org.alfresco.ext.documents.favourites.workspace://SpacesStore/" + file1.getNodeRef() +".createdAt")
+ .and().entriesListContains("value", "workspace://SpacesStore/" + file1.getNodeRef())
+ .and().entriesListContains("value", "true");
+
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("5");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListContains("id", "org.alfresco.ext.documents.favourites.workspace://SpacesStore/" + file2.getNodeRef() +".createdAt")
+ .and().entriesListContains("value", "workspace://SpacesStore/" + file2.getNodeRef())
+ .and().entriesListContains("value", "true");
+
+ STEP("12. Using FTP delete files.");
+ ftpProtocol.authenticateUser(testUser1).usingResource(file1).delete();
+ ftpProtocol.authenticateUser(testUser2).usingResource(file2).delete();
+
+ STEP("13. Using CMIS delete site1.");
+ dataSite.usingUser(admin).deleteSite(testSitePublic1);
+
+ STEP("14. Using RestAPI get preferences. Files and sites deleted are not listed anymore as favorites.");
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("2");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListContains("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListContains("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic2.getId()))
+ .and().entriesListDoesNotContain("id", "org.alfresco.ext.documents.favourites.workspace://SpacesStore/" + file1.getNodeRef() +".createdAt")
+ .and().entriesListDoesNotContain("value", "workspace://SpacesStore/" + file1.getNodeRef())
+ .and().entriesListContains("value", "true");
+
+ restPreferenceModelsCollection = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferences();
+ restPreferenceModelsCollection.assertThat().paginationField("count").is("2");
+ restPreferenceModelsCollection.assertThat().entriesListIsNotEmpty()
+ .and().entriesListDoesNotContain("id", String.format(PreferenceName.EXT_SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListDoesNotContain("id", String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic1.getId()))
+ .and().entriesListDoesNotContain("id", "org.alfresco.ext.documents.favourites.workspace://SpacesStore/" + file2.getNodeRef() +".createdAt")
+ .and().entriesListDoesNotContain("value", "workspace://SpacesStore/" + file2.getNodeRef())
+ .and().entriesListContains("value", "true");
+ }
+
+ /**
+ * Scenario 101
+ * 1. Using CMIS create test users: u1 and u2
+ * 2. U1 creates public test site U1 creates a public test site using CMIS
+ * 3. U1 adds U2 as site member with manager role using RestAPI
+ * 4. U2 adds site to favorites using RestAPI
+ * 5. U2 gets preference 'org.alfresco.ext.sites.favourites.testsite.createdAt' using RestAPI
+ * 6. U2 remove site from favorites using RestAPI
+ * 7. U2 gets preference 'org.alfresco.ext.sites.favourites.testsite.createdAt' using RestAPI
+ * 8. U2 creates file1 in test site's document library using FTP
+ * 9. U2 gets preference 'org.alfresco.ext.documents.favourites.workspace://SpacesStore/.createdAt' using RestAPI
+ * 10. U2 removes file1 from favorites using RestAPI
+ * 11. U2 gets preference 'org.alfresco.share.documents.favourite' using RestAPI
+ * 12. U2 renames file1 to file-updated with WebDAV
+ * 13. U2 gets preference 'org.alfresco.ext.documents.favourites.workspace://SpacesStore/.createdAt' using RestAPI
+ * 14. U2 deletes file-updated with CMIS
+ * 15. U2 gets preference 'org.alfresco.ext.documents.favourites.workspace://SpacesStore/.createdAt' using RestAPI
+ * 16. U2 adds site to favorites with RestAPI and U1 deletes site1 with CMIS
+ * 17. U2 gets preference 'org.alfresco.ext.sites.favourites.site1.createdAt' using RestAPI
+ */
+ @Bug(id = "ACE-5769")
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL})
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.PREFERENCES }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can get preference of sites and documents which were updated or deleted")
+ public void getPreferenceForSiteAndFiles() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates public test site U1 creates a public test site using CMIS");
+ SiteModel testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("3. U1 adds U2 as site member with manager role using RestAPI");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteManager);
+ testUser2.setUserRole(UserRole.SiteManager);
+
+ STEP("4. U2 adds site to favorites using RestAPI");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. U2 gets preference 'org.alfresco.ext.sites.favourites.testsite.createdAt' using RestAPI");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic.getId()));
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+
+ STEP("6. U2 remove site from favorites using RestAPI");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().removeFavoriteSite(testSitePublic);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("7. U2 gets preference 'org.alfresco.ext.sites.favourites.testsite.createdAt' using RestAPI");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic.getId()));
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+
+ STEP("8. U2 creates file1 in test site's document library using FTP and adds it to favorites using RestAPI");
+ FileModel file1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ ftpProtocol.authenticateUser(testUser2).usingSite(testSitePublic).createFile(file1);
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(file1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("9. U2 gets preference 'org.alfresco.ext.documents.favourites.workspace://SpacesStore/.createdAt' using RestAPI");
+ RestPreferenceModel preference = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ preference.assertThat().field("value").is("workspace://SpacesStore/" + file1.getNodeRefWithoutVersion());
+
+ STEP("10. U2 removes file1 from favorites using RestAPI");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().deleteFileFromFavorites(file1);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("11. U2 gets preference 'org.alfresco.share.documents.favourite' using RestAPI");
+ preference = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ preference.assertThat().field("value").isNull();
+
+ STEP("12. U2 adds file1 to favorites using RestAPI and renames file1 to file-updated with WebDAV");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(file1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ webDavProtocol.authenticateUser(testUser2).usingResource(file1).rename(file1.getName()+ "-updated");
+
+ STEP("13. U2 gets preference 'org.alfresco.ext.documents.favourites.workspace://SpacesStore/.createdAt' using RestAPI");
+ preference = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ preference.assertThat().field("value").is("workspace://SpacesStore/" + file1.getNodeRefWithoutVersion());
+
+ STEP("14. U2 adds file1 to favorites using RestAPI and deletes file-updated with CMIS");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(file1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ cmisAPI.authenticateUser(testUser2).usingResource(file1).delete();
+
+ STEP("15. U2 gets preference 'org.alfresco.ext.documents.favourites.workspace://SpacesStore/.createdAt' using RestAPI");
+ preference = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(PreferenceName.DOCUMENTS_FAVORITES_PREFIX.toString());
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ preference.assertThat().field("value").isNull();
+
+ STEP("16. U2 adds site to favorites with RestAPI and U1 deletes site1 with CMIS");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ dataSite.usingUser(testUser1).deleteSite(testSitePublic);
+
+ STEP("17. U2 gets preference 'org.alfresco.ext.sites.favourites.site1.createdAt' using RestAPI");
+ preference = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getPersonPreferenceInformation(String.format(PreferenceName.SITES_FAVORITES_PREFIX.toString(), testSitePublic.getId()));
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ preference.assertThat().field("value").isNull();
+ }
+
+ @Bug(id = "REPO-2419", status = Status.FIXED)
+ @Test(groups = { TestGroup.PROTOCOLS, TestGroup.WEBDAV, TestGroup.FULL })
+ @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.WEBDAV }, executionType = ExecutionType.REGRESSION, description = "Verify that the version of a new file uploaded through WebDAV is 1.0 with the real content size.")
+ public void uploadedFileThroughWebdavHasFirstVersion() throws Exception
+ {
+ UserModel managerUser = dataUser.createRandomTestUser();
+ SiteModel testSite = dataSite.usingUser(managerUser).createPublicRandomSite();
+
+ STEP("0. Verify versionable aspect is set for all contents using webscript");
+ String fileCreationWebScript = "alfresco/s/api/classes/cm_content";
+
+ RestAssured.basePath = "";
+ restAPI.configureRequestSpec().setBasePath(RestAssured.basePath);
+ RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, fileCreationWebScript);
+ RestResponse response = restAPI.authenticateUser(admin).process(request);
+ Assert.assertEquals(response.getResponse().getStatusCode(), HttpStatus.OK.value());
+ try
+ {
+ response.assertThat().body(containsString("cm:versionable"));
+ response.assertThat().body("defaultAspects.'cm:versionable'.title", equalTo("Versionable"));
+ }
+ catch(AssertionError ae)
+ {
+ throw new SkipException("Skipping this test because the versionable aspect is not applied. Please add "
+ + "the versionable aspect to all content in contentModel.xml and run the test again.");
+ }
+
+ STEP("1. Upload a local file on a new folder using WebDAV protocol");
+ FolderModel folder = dataContent.usingUser(managerUser).usingSite(testSite).createFolder();
+ File fileToUpload = Utility.getTestResourceFile("shared-resources/testdata/nonemptyupload.txt");
+ webDavProtocol.authenticateUser(managerUser).usingSite(testSite).usingResource(folder).uploadFile(fileToUpload);
+ FileModel file = new FileModel(fileToUpload.getName());
+
+ STEP("2. Verify version is exactly 1.0 and the size is the same as the local file");
+ dataContent.usingResource(file).assertContentVersionIs("1.0");
+ dataContent.usingResource(file).assertContentSizeIs(19);
+ }
+}
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTests1.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTests1.java
new file mode 100644
index 0000000000..c606dc17cf
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTests1.java
@@ -0,0 +1,477 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import io.restassured.RestAssured;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.dataprep.SiteService.Visibility;
+import org.alfresco.rest.core.RestRequest;
+import org.alfresco.rest.core.RestResponse;
+import org.alfresco.rest.model.RestSiteContainerModel;
+import org.alfresco.rest.model.RestSiteContainerModelsCollection;
+import org.alfresco.rest.model.RestSiteEntry;
+import org.alfresco.rest.model.RestSiteMemberModelsCollection;
+import org.alfresco.rest.model.RestSiteMembershipRequestModel;
+import org.alfresco.rest.model.RestTagModel;
+import org.alfresco.rest.model.RestTaskModel;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.constants.UserRole;
+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.GroupModel;
+import org.alfresco.utility.model.SiteModel;
+import org.alfresco.utility.model.TestGroup;
+import org.alfresco.utility.model.UserModel;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class IntegrationFullTests1 extends IntegrationTest
+{
+ UserModel testUser1, testUser2, testUser3;
+ SiteModel testSitePublic, testSiteModerated;
+
+ /**
+ * Scenario 87
+ * 1. Using RestApi Admin user creates a new group1
+ * 2. Using CMIS create test users: U1, U2 and U3
+ * 3. Using RestApi add users U2 and U3 to group1
+ * 4. U1 creates public test site1 using CMIS
+ * 5. U1 creates file1 using CMIS, WebDav, FTP
+ * 6. U1 apply Acl permission in the new documents for testGroup with role Site Consumer using CMIS
+ * 7. Get permissions for U2 using CMIS
+ * 8. U2 edits files created with CMIS, WebDav, FTP using WebDav
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify document permissions are added for a group of users")
+ public void addDocumentPermissionsForGroupOfUsers() throws Exception
+ {
+ STEP("1. Using RestApi Admin user creates a new group1");
+ GroupModel group1 = dataGroup.createRandomGroup();
+
+ STEP("2. Using CMIS create test users: U1, U2 and U3");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+ testUser3 = dataUser.createRandomTestUser();
+
+ STEP("3. Using RestApi add users U2 and U3 to group1");
+ dataGroup.usingUser(testUser2).addUserToGroup(group1);
+ dataGroup.usingUser(testUser3).addUserToGroup(group1);
+
+ STEP("4. U1 creates public test site1 using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("5. U1 creates file1 using CMIS, WebDav, FTP");
+ FileModel cmisFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFile(cmisFile);
+ FileModel webDavFile = FileModel.getRandomFileModel(FileType.HTML);
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(webDavFile);
+ FileModel ftpFile = FileModel.getRandomFileModel(FileType.XML);
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(ftpFile);
+
+ STEP("6. U1 apply Acl permission in the new documents for testGroup with role Site Consumer using CMIS");
+ cmisAPI.usingResource(cmisFile).addAcl(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(webDavFile).addAcl(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(ftpFile).addAcl(group1, UserRole.SiteConsumer);
+
+ STEP("7. Get permissions for U2 using CMIS");
+ cmisAPI.usingResource(cmisFile).assertThat().permissionIsSetForGrup(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(webDavFile).assertThat().permissionIsSetForGrup(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(ftpFile).assertThat().permissionIsSetForGrup(group1, UserRole.SiteConsumer);
+
+ STEP("8. U2 edits files created with CMIS, WebDav, FTP using WebDav");
+ String newContent = "new content";
+ webDavProtocol.authenticateUser(testUser2)
+ .usingResource(cmisFile).update(newContent)
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_FORBIDDEN)
+ .usingResource(webDavFile).update(newContent)
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_FORBIDDEN)
+ .usingResource(ftpFile).update(newContent)
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_FORBIDDEN);
+ }
+
+ /**
+ * Scenario 88
+ * 1. Using RestApi Admin user creates a new group1
+ * 2. Using CMIS create test users: U1, U2 and U3
+ * 3. Using RestApi add users U2 and U3 to group1
+ * 4. U1 creates public test site1 using CMIS
+ * 5. U1 creates folder1 using CMIS, WebDav, FTP
+ * 6. U1 apply Acl permission in the new folders for testGroup with role Site Consumer using CMIS
+ * 7. Get permissions for U2 using CMIS
+ * 8. U2 edits folders created with CMIS, WebDav, FTP using WebDav
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify folder permissions are added for a group of users")
+ public void addFolderPermissionsForGroupOfUsers() throws Exception
+ {
+ STEP("1. Using RestApi Admin user creates a new group1");
+ GroupModel group1 = dataGroup.createRandomGroup();
+
+ STEP("2. Using CMIS create test users: U1, U2 and U3");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+ testUser3 = dataUser.createRandomTestUser();
+
+ STEP("3. Using RestApi add users U2 and U3 to group1");
+ dataGroup.usingUser(testUser2).addUserToGroup(group1);
+ dataGroup.usingUser(testUser3).addUserToGroup(group1);
+
+ STEP("4. U1 creates public test site1 using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("5. U1 creates folders using CMIS, WebDav, FTP");
+ FolderModel cmisFolder = FolderModel.getRandomFolderModel();
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(cmisFolder);
+ FolderModel webDavFolder = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(webDavFolder);
+ FolderModel ftpFolder = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(ftpFolder);
+
+ STEP("6. U1 apply Acl permission in the new folders for testGroup with role Site Consumer using CMIS");
+ cmisAPI.usingResource(cmisFolder).addAcl(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(webDavFolder).addAcl(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(ftpFolder).addAcl(group1, UserRole.SiteConsumer);
+
+ STEP("7. Get permissions for U2 using CMIS");
+ cmisAPI.usingResource(cmisFolder).assertThat().permissionIsSetForGrup(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(webDavFolder).assertThat().permissionIsSetForGrup(group1, UserRole.SiteConsumer);
+ cmisAPI.usingResource(ftpFolder).assertThat().permissionIsSetForGrup(group1, UserRole.SiteConsumer);
+
+ STEP("8. U2 edits folders created with CMIS, WebDav, FTP using WebDav");
+ String newName = "newName";
+ webDavProtocol.authenticateUser(testUser2)
+ .usingResource(cmisFolder).rename(newName)
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_FORBIDDEN)
+ .usingResource(webDavFolder).rename(newName)
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_FORBIDDEN)
+ .usingResource(ftpFolder).rename(newName)
+ .assertThat().hasStatus(org.apache.commons.httpclient.HttpStatus.SC_FORBIDDEN);
+ }
+
+ /**
+ * Scenario 102
+ * 1. Using CMIS create test users: U1 and U2
+ * 2. U1 creates moderated test site1 using CMIS
+ * 3. U2 creates site membership request to site1 with RestAPI
+ * 4. U2 gets site membership request, check new message using RestAPI
+ * 5. U2 updates site membership request with a new message using RestAPI
+ * 6. U2 gets site membership request, check new message using RestAPI
+ * 7. U1 changes site visibility to private site using RestAPI
+ * 8. U2 updates site membership request with a new message using RestAPI
+ * 9. U2 gets site membership request, check new message using RestAPI
+ * 10. U1 change site visibility to moderated site RestAPI
+ * 11. U2 gets site membership request, check new message using RestAPI
+ * 12. U2 updates site membership request with a new message using RestAPI
+ * 13. U2 get site membership request, check new message using RestAPI
+ * 14. U1 user1 changes site visibility to public using RestAPI
+ * 15. U2 updates site membership request with a new message with RestAPI
+ * 16. U2 gets site membership request, check new message using RestAPI
+ * 17. U1 changes site visibility to moderated site RestAPI");
+ * 18. U2 gets site membership request, check new message using RestAPI");
+ * 19. U2 updates new site membership request using RestAPI
+ * 20. U1 approves site membership using RestAPI
+ * 21. U2 gets site membership request - no request using RestAPI
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.REGRESSION,
+ description = "Verify user can update or not site membership request when site visibility is updated")
+ public void updateSiteMembershipRequestWhenSiteVisibilityIsUpdated() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: U1 and U2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates moderated test site1 using CMIS");
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+
+ STEP("3. U2 creates site membership request to site1 with RestAPI");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingMe().addSiteMembershipRequest("Please add me 1", testSiteModerated, "Request1");
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("4. U2 gets site membership request, check new message using RestAPI");
+ RestSiteMembershipRequestModel request = restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ request.assertThat().field("message").is("Please add me 1");
+
+ STEP("5. U2 updates site membership request with a new message using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().updateSiteMembershipRequest(testSiteModerated, "Please add me 2");
+ request.assertThat().field("message").is("Please add me 2");
+
+ STEP("6. U2 gets site membership request, check new message using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ request.assertThat().field("message").is("Please add me 2");
+
+ STEP("7. U1 changes site visibility to private site using RestAPI");
+ dataSite.usingUser(testUser1).updateSiteVisibility(testSiteModerated, Visibility.PRIVATE);
+
+ STEP("8. U2 updates site membership request with a new message using RestAPI");
+ restAPI.withCoreAPI().usingMe().updateSiteMembershipRequest(testSiteModerated, "Please add me 2");
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+
+ STEP("9. U2 gets site membership request, check new message using RestAPI");
+ restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+
+ STEP("10. U1 change site visibility to moderated site RestAPI");
+ dataSite.usingUser(testUser1).updateSiteVisibility(testSiteModerated, Visibility.MODERATED);
+
+ STEP("11. U2 gets site membership request, check new message using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ request.assertThat().field("message").is("Please add me 2");
+
+ STEP("12. U2 updates site membership request with a new message using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().updateSiteMembershipRequest(testSiteModerated, "Please add me 3");
+ request.assertThat().field("message").is("Please add me 3");
+
+ STEP("13. U2 get site membership request, check new message using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ request.assertThat().field("message").is("Please add me 3");
+
+ STEP("14. U1 user1 changes site visibility to public using RestAPI");
+ dataSite.usingUser(testUser1).updateSiteVisibility(testSiteModerated, Visibility.PUBLIC);
+
+ STEP("15. U2 updates site membership request with a new message with RestAPI");
+ restAPI.withCoreAPI().usingMe().updateSiteMembershipRequest(testSiteModerated, "Please add me 4");
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+
+ STEP("16. U2 gets site membership request, check new message using RestAPI");
+ restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+
+ STEP("17. U1 changes site visibility to moderated site RestAPI");
+ dataSite.usingUser(testUser1).updateSiteVisibility(testSiteModerated, Visibility.MODERATED);
+
+ STEP("18. U2 gets site membership request, check new message using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ request.assertThat().field("message").is("Please add me 3");
+
+ STEP("19. U2 updates new site membership request using RestAPI");
+ request = restAPI.withCoreAPI().usingMe().updateSiteMembershipRequest(testSiteModerated, "Please add me 5");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ request.assertThat().field("message").is("Please add me 5");
+
+ STEP("20. U1 approves site membership using RestAPI");
+ RestTaskModel taskModel = restAPI.withWorkflowAPI().getTasks().getTaskModelByDescription(testSiteModerated);
+ workflow.approveSiteMembershipRequest(testUser1.getUsername(), testUser1.getPassword(), taskModel.getId(), true, "Approve");
+
+ STEP("21. U2 gets site membership request - no request using RestAPI");
+ restAPI.withCoreAPI().usingMe().getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+ RestSiteEntry site= restAPI.withCoreAPI().usingMe().getSiteMembership(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ site.assertThat().field("id").is(testSiteModerated.getId())
+ .and().field("role").isNotEmpty();
+ }
+
+ /**
+ * Scenario 104
+ * 1. Using CMIS create test user A1
+ * 2. A1 creates public test site1 using CMIS
+ * 3. Using CMIS create test user U1
+ * 4. A1 adds U1 to site1 as site manager using RestAPI
+ * 5. A1 get site members using RestAPI
+ * 6. Using CMIS create test user U2
+ * 7. A1 adds U2 to site1 as site collaborator using RestAPI
+ * 8. A1 get site members using RestAPI
+ * 9. Using CMIS create test user U3
+ * 10. A1 add U3 to site1 as site contributor using RestAPI
+ * 11. A1 get site members using RestAPI
+ * 12. Using CMIS create test user U4
+ * 13. A1 add U4 to site1 as site consumer using RestAPI
+ * 14. A1 get site members using RestAPI
+ * 15. Using CMIS delete test user U1
+ * 16. A1 get site members using RestAPI
+ * 17. Using CMIS delete test user U2
+ * 18. A1 get site members using RestAPI
+ * 19. Using CMIS delete test user U3
+ * 20. A1 get site members using RestAPI
+ * 21. Using CMIS delete test user U4
+ * 22. A1 get site members using RestAPI
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.REGRESSION,
+ description = "Verify get site members when users are added to site or deleted")
+ public void getSiteMembersWhenUsersAreAddedOrDeleted() throws Exception
+ {
+ STEP("1. Using CMIS create test user A1");
+ UserModel testUser = dataUser.createRandomTestUser();
+
+ STEP("2. A1 creates public test site1 using CMIS");
+ testSitePublic = dataSite.usingUser(testUser).createPublicRandomSite();
+
+ STEP("3. Using CMIS create test user U1");
+ UserModel user1 = dataUser.createRandomTestUser();
+
+ STEP("4. A1 adds U1 to site1 as site manager using RestAPI");
+ user1.setUserRole(UserRole.SiteManager);
+ restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).addPerson(user1);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("5. A1 get site members using RestAPI");
+ RestSiteMemberModelsCollection members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("2");
+ members.assertThat().entriesListContains("id", user1.getUsername())
+ .and().entriesListContains("role", UserRole.SiteManager.toString());
+
+ STEP("6. Using CMIS create test user U2");
+ UserModel user2 = dataUser.createRandomTestUser();
+
+ STEP("7. A1 adds U2 to site1 as site collaborator using RestAPI");
+ user2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).addPerson(user2);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("8. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("3");
+ members.assertThat().entriesListContains("id", user2.getUsername())
+ .and().entriesListContains("role", UserRole.SiteCollaborator.toString());
+
+ STEP("9. Using CMIS create test user U3");
+ UserModel user3 = dataUser.createRandomTestUser();
+
+ STEP("10. A1 add U3 to site1 as site contributor using RestAPI");
+ user3.setUserRole(UserRole.SiteContributor);
+ restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).addPerson(user3);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("11. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("4");
+ members.assertThat().entriesListContains("id", user3.getUsername())
+ .and().entriesListContains("role", UserRole.SiteContributor.toString());
+
+ STEP("12. Using CMIS create test user U4");
+ UserModel user4 = dataUser.createRandomTestUser();
+
+ STEP("13. A1 add U4 to site1 as site consumer using RestAPI");
+ user4.setUserRole(UserRole.SiteConsumer);
+ restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).addPerson(user4);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("14. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("5");
+ members.assertThat().entriesListContains("id", user4.getUsername())
+ .and().entriesListContains("role", UserRole.SiteConsumer.toString());
+
+ STEP("15. Using CMIS delete test user U1");
+ dataUser.deleteUser(user1);
+
+ STEP("16. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("4");
+ members.assertThat().entriesListDoesNotContain("id", user1.getUsername());
+
+ STEP("17. Using CMIS delete test user U2");
+ dataUser.deleteUser(user2);
+
+ STEP("18. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("3");
+ members.assertThat().entriesListDoesNotContain("id", user2.getUsername());
+
+ STEP("19. Using CMIS delete test user U3");
+ dataUser.deleteUser(user3);
+
+ STEP("20. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("2");
+ members.assertThat().entriesListDoesNotContain("id", user3.getUsername());
+
+ STEP("21. Using CMIS delete test user U4");
+ dataUser.deleteUser(user4);
+
+ STEP("22. A1 get site members using RestAPI");
+ members = restAPI.authenticateUser(testUser).withCoreAPI().usingSite(testSitePublic).getSiteMembers();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ members.assertThat().paginationField("count").is("1");
+ members.assertThat().entriesListDoesNotContain("id", user4.getUsername());
+ }
+
+ /**
+ * Scenario 105
+ * 1. Using CMIS create test user U1
+ * 2. U1 creates public test site1 using CMIS
+ * 3. U1 creates file1 using Webdav
+ * 4. U1 updates file1 properties using CMIS
+ * 5. U1 gets file1 properties using CMIS
+ * 6. U1 renames file1 using Webdav
+ * 7. U1 updates file1 content using FTP
+ * 8. U1 adds tags to file1 using RestAPI
+ * 9. U1 updates file1 properties using CMIS
+ * 10. U1 gets file1 properties using CMIS
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify file properties with file properties are updated")
+ public void checkFilePropertiesWhenFileIsUpdated() throws Exception
+ {
+ STEP("1. Using CMIS create test user U1");
+ UserModel testUser = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates public test site1 using CMIS");
+ testSitePublic = dataSite.usingUser(testUser).createPublicRandomSite();
+
+ STEP("3. U1 creates file1 using Webdav");
+ FileModel file1 = FileModel.getRandomFileModel(FileType.MSWORD2007);
+ file1.setContent("content1");
+ webDavProtocol.authenticateUser(testUser).usingSite(testSitePublic).createFile(file1);
+
+ STEP("4. U1 updates file1 properties using CMIS");
+ String newDescription = "New-" + file1.getDescription();
+ String newTitle = "New title-" +file1.getTitle();
+ cmisAPI.authenticateUser(testUser).usingSite(testSitePublic).usingResource(file1).updateProperty("cmis:description", newDescription)
+ .updateProperty("cm:title", newTitle);
+
+ STEP("5. U1 gets file1 properties using CMIS");
+ cmisAPI.authenticateUser(testUser).usingResource(file1).assertThat().contentPropertyHasValue("cmis:description", newDescription)
+ .assertThat().contentPropertyHasValue("cm:title", newTitle);
+
+ STEP("6. U1 renames file1 using Webdav");
+ String newName = "Edited-" + file1.getName();
+ webDavProtocol.authenticateUser(testUser).usingSite(testSitePublic).usingResource(file1).rename(newName);
+
+ STEP("7. U1 updates file1 content using FTP");
+ String newContent = "New " + file1.getContent();
+ ftpProtocol.authenticateUser(testUser).usingSite(testSitePublic).usingResource(file1).update(newContent)
+ .assertThat().contentIs(newContent);
+
+ STEP("8. U1 adds tags to file1 using RestAPI");
+ String newTag = RandomData.getRandomName("tag");
+ RestTagModel tag = restAPI.authenticateUser(testUser).withCoreAPI().usingResource(file1).addTag(newTag);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("9. U1 updates file1 properties using CMIS");
+ newTitle = "New title2-" + file1.getTitle();
+ cmisAPI.authenticateUser(testUser).usingSite(testSitePublic).usingResource(file1).updateProperty("cm:title", newTitle);
+
+ STEP("10. U1 gets file1 properties using CMIS");
+ cmisAPI.authenticateUser(testUser).usingResource(file1).assertThat().contentPropertyHasValue("cmis:description", newDescription)
+ .assertThat().contentPropertyHasValue("cm:title", newTitle)
+ .assertThat().contentPropertyHasValue("cmis:name", newName)
+ .assertThat().contentPropertyHasValue("cm:taggable", tag.getId())
+ .assertThat().contentIs(newContent);
+ }
+}
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTestsBulk2.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTestsBulk2.java
new file mode 100644
index 0000000000..74d12a0641
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTestsBulk2.java
@@ -0,0 +1,490 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import org.alfresco.rest.model.RestErrorModel;
+import org.alfresco.rest.model.RestTagModel;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.data.DataUser.ListUserWithRoles;
+import org.alfresco.utility.exception.DataPreparationException;
+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.springframework.http.HttpStatus;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+public class IntegrationFullTestsBulk2 extends IntegrationTest
+{
+ private UserModel testUser1;
+ private SiteModel testSitePublic;
+ private FolderModel testFolder1, testFolder2;
+ private FileModel wordFile, testFile;
+ private ListUserWithRoles usersWithRoles;
+
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ testUser1 = dataUser.createRandomTestUser();
+
+ wordFile = FileModel.getRandomFileModel(FileType.MSWORD2007, "tasTesting");
+ }
+
+ @BeforeMethod(alwaysRun = true)
+ public void setup() throws DataPreparationException {
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFolder2 = FolderModel.getRandomFolderModel();
+ testFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "testContent");
+ }
+
+ /**
+ * Scenario 73
+ * 1. Create file1 using ftp
+ * 2. Open document for edit using CMIS
+ * 3. Try to edit document using Webdav while checked-out with CMIS
+ * 4. Copy document to testFolder2 with ftp
+ * 5. Update document from folder2, check its content is updated with Webdav
+ * 6. Update document with WebDAV - should fail since document is checked out
+ *
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Edit checked out document using several protocols")
+ public void updateFileUsingDifferentProtocolsWhileDocumentIsCheckedOut() throws Exception
+ {
+ STEP("1. Create testFile1 using ftp");
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1)
+ .usingResource(testFolder1).createFile(wordFile)
+ .assertThat().contentIs("tasTesting");
+
+ STEP("2. Open document for edit using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(wordFile).checkOut();
+ FileModel wordFilePWC = cmisAPI.usingResource(wordFile).withCMISUtil().getPWCFileModel();
+
+ STEP("3. Try to edit document using Webdav while checked-out with CMIS - content should be updated");
+ webDavProtocol.authenticateUser(testUser1).usingResource(wordFilePWC).update("update")
+ .and().assertThat().contentIs("update");
+
+ STEP("4. Copy document to testFolder2 with ftp");
+ FileModel copiedWordFile = new FileModel(wordFile);
+ ftpProtocol.usingSite(testSitePublic).createFolder(testFolder2)
+ .usingResource(wordFile).copyTo(testFolder2);
+ copiedWordFile.setCmisLocation(ftpProtocol.getLastResourceWithoutPrefix());
+ ftpProtocol.usingResource(testFolder1).assertThat().hasFiles(wordFile)
+ .and().usingResource(testFolder2).assertThat().hasFiles(copiedWordFile);
+
+ STEP("5. Update document from folder2, check its content is updated with Webdav");
+ webDavProtocol.usingResource(copiedWordFile).update("Step5")
+ .and().assertThat().contentIs("Step5");
+
+ STEP("6. Update document with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(wordFile).update("WebDAVUpdate");
+ }
+
+ /**
+ * Scenario 84
+ * 1. Create folder1 with webdav
+ * 2. Upload new file, file1 with ftp
+ * 3. Set content for file1 with cmis
+ * 4. CheckOut file1 with cmis
+ * 5. Try to edit file while checked-out with ftp
+ * 6. Cancel checkout with cmis
+ * 7. Try again to edit file with ftp
+ * 8. Edit file content using webDav
+ * 9. Get content using cmis, validate it
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL } )
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Update checked out document")
+ public void updateCheckedOutFile() throws Exception
+ {
+ STEP("1. Create folder1 with webdav");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).and().assertThat().existsInRepo();
+
+ STEP("2. Upload new file, file1 with ftp");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile)
+ .and().assertThat().existsInRepo().and().assertThat().existsInFtp();
+
+ STEP("3. Set content for file1 with cmis");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile).update("cmisUpdate")
+ .and().assertThat().contentIs("testContentcmisUpdate");
+
+ STEP("4. CheckOut file1 with cmis");
+ cmisAPI.usingResource(testFile).checkOut();
+
+ STEP("5. Try to edit file while checked-out with ftp - content should not be updated since file is checked out");
+ ftpProtocol.usingResource(testFile).update("ftpUpdate")
+ .and().assertThat().contentIs("testContentcmisUpdate");
+
+ STEP("6. Cancel checkout with cmis");
+ cmisAPI.usingResource(testFile).cancelCheckOut();
+
+ STEP("7. Try again to edit file with ftp");
+ ftpProtocol.usingResource(testFile).update("ftpUpdate")
+ .and().assertThat().contentIs("ftpUpdate");
+
+ STEP("8. Edit file content using webDav");
+ webDavProtocol.usingResource(testFile).update("webdavUpdate").and().assertThat().contentIs("webdavUpdate");
+
+ STEP("9. Get content using cmis, validate it");
+ cmisAPI.usingResource(testFile).assertThat().contentIs("webdavUpdate");
+ }
+
+ /**
+ * 1. Create folder1 with cmis
+ * 2. Add new file with webdav
+ * 3. Open file with Manager, add some content, save with webdav
+ * 4. Open file with Consumer, add some content, save with ftp
+ * 5. Open file with Contributor, delete some content, save with webdav
+ * 6. Open file with Collaborator, add some content, save with WebDAV
+ * 7. Open file with Consumer, delete some content, save with webdav
+ * 8. Open file with Manager, add new content, save with cmis
+ * 9. Open file with Collaborator, delete content that Manager added with ftp
+ * 10. Open file with Manager, add new content with webdav
+ * 11. Delete all content with admin using FTP
+ * 12. Delete file with cmis
+ * 13. Check file is deleted with WebDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Update file with different user roles and protocols")
+ public void updateFileWithDifferentRolesUsingDifferentProtocols() throws Exception
+ {
+ usersWithRoles = dataUser.addUsersWithRolesToSite(testSitePublic, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer,
+ UserRole.SiteContributor);
+
+ STEP("1. Create folder1 with cmis");
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).and().assertThat().existsInRepo();
+
+ STEP("2. Add new file with webdav");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile).and().assertThat().existsInRepo();
+
+ STEP("3. Open file with Manager, add some content, save with webdav");
+ webDavProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)).usingResource(testFile).update("webdavUpdate")
+ .and().assertThat().contentIs("webdavUpdate");
+
+ STEP("4. Open file with Consumer, add some content, save with ftp");
+ ftpProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
+ .usingResource(testFile).update("ftpUpdate").and().assertThat().contentIs("webdavUpdate");
+
+ STEP("5. Open file with Contributor, delete some content, save with webdav");
+ webDavProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
+ .usingResource(testFile).update("webdavUpdate").and().assertThat().contentIs("webdavUpdate");
+
+ STEP("6. Open file with Collaborator, add some content, save with WebDAV");
+ webDavProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
+ .usingResource(testFile).update("webdavUpdate2").and().assertThat().contentIs("webdavUpdate2");
+
+ STEP("7. Open file with Consumer, delete some content, save with webdav");
+ webDavProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer))
+ .usingResource(testFile).update("webdavUpdate3").and().assertThat().contentIs("webdavUpdate2");
+
+ STEP("8. Open file with Manager, add new content, save with cmis");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
+ .usingResource(testFile).update("cmisUpdate").and().assertThat().contentIs("webdavUpdate2cmisUpdate");
+
+ STEP("9. Open file with Collaborator, delete content that Manager added with ftp");
+ ftpProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
+ .usingResource(testFile).update("ftpUpdate").and().assertThat().contentIs("ftpUpdate");
+
+ STEP("10. Open file with Contributor, add new page with webdav");
+ webDavProtocol.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager))
+ .usingResource(testFile).update("webdavUpdate").and().assertThat().contentIs("webdavUpdate");
+
+ STEP("11. Delete all content with admin using FTP");
+ ftpProtocol.authenticateUser(dataUser.getAdminUser())
+ .usingResource(testFile).update("").and().assertThat().contentIs("");
+
+ STEP("12. Delete file with cmis");
+ cmisAPI.usingResource(testFile).delete().and().assertThat().doesNotExistInRepo();
+
+ STEP("13. Check file is deleted with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile).assertThat().doesNotExistInWebdav();
+ }
+
+ /**
+ * 1. Add file1 to document library with ftp
+ * 2. Update file content with WebDAV
+ * 3. Add a minor change to a document with cmis
+ * 4. Add a change with webdav, check document version with cmis
+ * 5. Add a major change to a document with cmis
+ * 6. Delete document last version with cmis
+ * 7. Try to edit previous version with cmis
+ * 8. Update content with ftp, check version
+ * 9. Check document content with WebDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Check document versioning")
+ public void documentVersioningTest() throws Exception
+ {
+ STEP("1. Add file1 to document library with ftp");
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile).and().assertThat().existsInRepo();
+
+ STEP("2. Update file content with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile).update("WebDAVUpdate").and().assertThat().contentIs("WebDAVUpdate");
+
+ STEP("3. Add a minor change to a document with cmis");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile).update("cmisUpdate")
+ .then().assertThat().documentHasVersion(1.1).and().assertThat().contentIs("WebDAVUpdatecmisUpdate");
+
+ STEP("4. Check document version with webdav");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile).update("webdavUpdate");
+ cmisAPI.assertThat().documentHasVersion(1.2);
+
+ STEP("5. Add a major change to a document with cmis");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile).checkOut().prepareDocumentForCheckIn().withMajorVersion().checkIn()
+ .and().assertThat().documentHasVersion(2.0);
+
+ STEP("6. Delete document last version with cmis");
+ cmisAPI.usingResource(testFile).deleteAllVersions(false).and().assertThat().documentHasVersion(1.2);
+
+ STEP("7. Try to edit previous version with cmis");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile).update("cmisUpdate")
+ .then().assertThat().documentHasVersion(1.3).and().assertThat().contentIs("webdavUpdatecmisUpdate");
+
+ STEP("8. Update content with ftp, check version");
+ ftpProtocol.usingResource(testFile).update("ftpUpdate");
+ cmisAPI.assertThat().documentHasVersion(1.4);
+
+ STEP("9. Check document content with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile).assertThat().contentIs("ftpUpdate");
+ }
+
+ /**
+ * Scenario 82
+ * 1. Create user1, user2
+ * 2. User1 creates site1 and invites user2 as manager
+ * 3. User1 adds document1 and tag1 to doc
+ * 4. User2 gets tags and verifies tag1 appears
+ * 5. User2 delete tag1
+ * 6. User1 tries to update tag1
+ * 7. User1 add new tag tag2
+ * 8. User2 verifies tag2 appears and tag1 is not in the list
+ * 9. User2 deletes document1
+ * 10. User1 tries to delete tag2
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT, TestGroup.TAGS }, executionType = ExecutionType.REGRESSION, description = "Check negative scenarios for tags")
+ public void tagsNegativeScenariosTest() throws Exception
+ {
+ STEP("1. Create user1, user2");
+ UserModel user1 = dataUser.createRandomTestUser();
+ UserModel user2 = dataUser.createRandomTestUser();
+ user2.setUserRole(UserRole.SiteManager);
+
+ STEP("2. User1 creates site1 and invites user2 as manager");
+ SiteModel site = dataSite.usingUser(user1).createPublicRandomSite();
+ restAPI.authenticateUser(user1).withCoreAPI().usingSite(site).addPerson(user2);
+
+ STEP("3. User1 adds document1 and tag1 to doc");
+ dataContent.usingUser(user1).usingSite(site).createContent(testFile);
+ RestTagModel tag = restAPI.withCoreAPI().usingResource(testFile).addTag("tag1");
+ restAPI.withCoreAPI().usingResource(testFile).getNodeTags().assertThat().entriesListContains("tag", "tag1");
+
+ STEP("4. User2 gets tags and verifies tag1 appears");
+ restAPI.authenticateUser(user2).withCoreAPI().usingResource(testFile).getNodeTags().assertThat().entriesListContains("tag", "tag1");
+
+ STEP("5. User2 delete tag1");
+ restAPI.withCoreAPI().usingResource(testFile).deleteTag(tag);
+ restAPI.withCoreAPI().usingResource(testFile).getNodeTags().assertThat().entriesListDoesNotContain("tag", "tag1");
+
+ STEP("6. User1 tries to update tag1");
+ restAPI.authenticateUser(user2).withCoreAPI().usingTag(tag).update("updatedTag");
+ restAPI.assertStatusCodeIs(HttpStatus.FORBIDDEN)
+ .assertLastError().containsSummary(RestErrorModel.PERMISSION_WAS_DENIED)
+ .containsErrorKey(RestErrorModel.PERMISSION_DENIED_ERRORKEY);
+
+ STEP("7. User1 add new tag tag2");
+ tag = restAPI.authenticateUser(user1).withCoreAPI().usingResource(testFile).addTag("tag2");
+ restAPI.withCoreAPI().usingResource(testFile).getNodeTags().assertThat().entriesListContains("tag", "tag2");
+
+ STEP("8. User2 verifies tag2 appears and tag1 is not in the list");
+ restAPI.authenticateUser(user2).withCoreAPI().usingResource(testFile).getNodeTags()
+ .assertThat().entriesListDoesNotContain("tag", "tag1")
+ .assertThat().entriesListContains("tag", "tag2");
+
+ STEP("9. User2 deletes document1");
+ dataContent.usingUser(user2).usingResource(testFile).deleteContent();
+
+ STEP("10. User1 tries to delete tag2");
+ restAPI.authenticateUser(user1).withCoreAPI().usingResource(testFile).deleteTag(tag);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND)
+ .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile.getNodeRefWithoutVersion()))
+ .containsErrorKey(RestErrorModel.ENTITY_NOT_FOUND_ERRORKEY);
+ }
+
+ /**
+ * Scenario 83
+ * 1. Create user1, user2
+ * 2. User1 creates site1 and invites user2 as manager with rest api
+ * 3. User1 adds document1 with webdav
+ * 4. User2 reads the document1 with ftp
+ * 5. User1 update document1 with WebDAV
+ * 6. User2 update the document1 with WebDAV
+ * 7. User1 deletes the document1 with ftp
+ * 8. Verify user2 cannot update document1 with cmis
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL }, expectedExceptions = CmisObjectNotFoundException.class, expectedExceptionsMessageRegExp = ".*Object not found:.*")
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Negative scenarios for update document")
+ public void fileUpdateNegativeScenariosTest() throws Exception
+ {
+ STEP("1. Create user1, user2");
+ UserModel user1 = dataUser.createRandomTestUser();
+ UserModel user2 = dataUser.createRandomTestUser();
+ user2.setUserRole(UserRole.SiteManager);
+
+ STEP("2. User1 creates site1 and invites user2 as manager with rest api");
+ SiteModel site = dataSite.usingUser(user1).createPublicRandomSite();
+ restAPI.authenticateUser(user1).withCoreAPI().usingSite(site).addPerson(user2);
+
+ STEP("3. User1 adds document1 with webdav");
+ webDavProtocol.authenticateUser(user1).usingSite(site).createFile(testFile).and().assertThat().existsInRepo();
+
+ STEP("4. User2 reads the document1 with ftp");
+ ftpProtocol.authenticateUser(user2).usingResource(testFile).assertThat().contentIs("testContent");
+
+ STEP("5. User1 update document1 with WebDAV");
+ webDavProtocol.authenticateUser(user1).usingResource(testFile).update("WebDAVUpdate1").assertThat().contentIs("WebDAVUpdate1");
+
+ STEP("6. User2 update the document1 with WebDAV");
+ webDavProtocol.authenticateUser(user2).usingResource(testFile).update("WebDAVUpdate2").assertThat().contentIs("WebDAVUpdate2");
+
+ STEP("7. User1 deletes the document1 with ftp");
+ ftpProtocol.authenticateUser(user1).usingResource(testFile).delete().assertThat().doesNotExistInFtp().assertThat().doesNotExistInRepo();
+
+ STEP("8. Verify user2 cannot update document1 with cmis");
+ cmisAPI.authenticateUser(user2).usingResource(testFile).update("cmisUpdate");
+ }
+
+ /**
+ * Scenario 85
+ * 1. Upload file with CMIS
+ * 2. Add some content with ftp
+ * 3. Add a minor change to document, 1.2 with cmis
+ * 4. Add a major change to document, 2.0 with cmis
+ * 5. Add a minor change to document, 2.1 with cmis
+ * 6. Delete version 2.0 with cmis with cmis
+ * 7. Get document version with cmis
+ * 8. Try to edit version 2.0 with cmis
+ * 9. Delete version 2.1 with cmis
+ * 10. Get document version with cmis
+ * 11. Try to edit version 2.0 with cmis
+ * 12. Check document content with ftp
+ * 13. Check document version with cmis
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "File versioning test scenarios")
+ public void fileVersioningScenariosTest() throws Exception
+ {
+ STEP("1. Upload file with CMIS");
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile).and().assertThat().existsInRepo();
+
+ STEP("2. Add some content with ftp ");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFile).update("ftpUpdate").and().assertThat().contentIs("ftpUpdate");
+
+ STEP("3. Add a minor change to document, 1.1 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMinorVersion().checkIn().refreshResource().and().assertThat().documentHasVersion(1.2);
+
+ STEP("4. Add a major change to document, 2.0 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMajorVersion().checkIn().and().assertThat().documentHasVersion(2.0);
+
+ STEP("5. Add a minor change to document, 2.1 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMinorVersion().checkIn().and().assertThat().documentHasVersion(2.1);
+
+ STEP("6. Delete version 2.0 with cmis with cmis");
+ cmisAPI.usingResource(testFile).deleteAllVersions(false);
+
+ STEP("7. Get document version with cmis");
+ cmisAPI.usingResource(testFile).assertThat().documentHasVersion(2.0);
+
+ STEP("8. Try to edit version 2.0 with cmis");
+ cmisAPI.usingResource(testFile).update("cmisUpdate").and().assertThat().contentIs("cmisUpdatecmisUpdate")
+ .and().assertThat().documentHasVersion(2.1);
+
+ STEP("9. Delete version 2.1 with cmis");
+ cmisAPI.usingResource(testFile).deleteAllVersions(false);
+
+ STEP("10. Get document version with cmis");
+ cmisAPI.usingResource(testFile).assertThat().documentHasVersion(2.0);
+
+ STEP("11. Try to edit version 2.0 with cmis");
+ cmisAPI.usingResource(testFile).update("cmisUpdate").and().assertThat().contentIs("cmisUpdatecmisUpdate")
+ .and().assertThat().documentHasVersion(2.1);
+
+ STEP("12. Update and check document content with ftp");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFile).update("ftpUpdate").assertThat().contentIs("ftpUpdate");
+
+ STEP("13. Check document version with cmis");
+ cmisAPI.usingResource(testFile).assertThat().documentHasVersion(2.2);
+ }
+
+ /**
+ * 1. Upload file with cmis
+ * 2. Add some content with WebDAV
+ * 3. Add a minor change to document, 1.2 with cmis
+ * 4. Add a major change to document, 2.0 with cmis
+ * 5. Add a minor change to document, 2.1 with cmis
+ * 6. Delete version 2.1 with cmis
+ * 7. Try to edit the last version (which is now 2.0) with webdav
+ * 8. Check version with CMIS
+ * 9. Add new major change, version 3.0 with cmis
+ * 10. Delete previous version with cmis
+ * 11. Delete document with ftp
+ * 12. Check document version with cmis
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL }, expectedExceptionsMessageRegExp = ".*Version Series not found.*",
+ expectedExceptions = CmisObjectNotFoundException.class)
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "File versioning additional test scenarios")
+ public void fileVersioningNegativeScenariosTest() throws Exception
+ {
+ STEP("1. Upload file with cmis");
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile).and().assertThat().existsInRepo();
+
+ STEP("2. Add some content with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile).update("WebDAVUpdate").and().assertThat().contentIs("WebDAVUpdate");
+
+ STEP("3. Add a minor change to document, 1.2 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMinorVersion().checkIn().refreshResource().and().assertThat().documentHasVersion(1.2);
+
+ STEP("4. Add a major change to document, 2.0 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMajorVersion().checkIn().and().assertThat().documentHasVersion(2.0);
+
+ STEP("5. Add a minor change to document, 2.1 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMinorVersion().checkIn().refreshResource().and().assertThat().documentHasVersion(2.1);
+
+ STEP("6. Delete version 2.1 with cmis");
+ cmisAPI.usingResource(testFile).deleteAllVersions(false).assertThat().documentHasVersion(2.0);
+
+ STEP("7. Try to edit the last version (which is now 2.0) with webdav");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile).update("webdavUpdate");
+
+ STEP("8. Check version with CMIS");
+ cmisAPI.usingResource(testFile).assertThat().documentHasVersion(2.1);
+
+ STEP("9. Add new major change, version 3.0 with cmis");
+ cmisAPI.usingResource(testFile).checkOut().prepareDocumentForCheckIn().withContent("cmisUpdate")
+ .withMajorVersion().checkIn().and().assertThat().documentHasVersion(3.0);
+
+ STEP("10. Delete previous version with cmis");
+ cmisAPI.usingResource(testFile).deleteAllVersions(false).assertThat().documentHasVersion(2.1);
+
+ STEP("11. Delete document with ftp");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFile).delete().assertThat().doesNotExistInRepo();
+
+ STEP("12. Check document version with cmis - should fail");
+ cmisAPI.usingResource(testFile).assertThat().documentHasVersion(2.1);
+ }
+}
\ No newline at end of file
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTestsBulk3.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTestsBulk3.java
new file mode 100644
index 0000000000..5a855da02d
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationFullTestsBulk3.java
@@ -0,0 +1,433 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import org.alfresco.rest.model.RestCommentModelsCollection;
+import org.alfresco.rest.model.RestErrorModel;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.data.DataUser.ListUserWithRoles;
+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.springframework.http.HttpStatus;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class IntegrationFullTestsBulk3 extends IntegrationTest
+{
+ private UserModel testUser1, testUser2;
+ private SiteModel publicSite, moderatedSite, privateSite;
+ private RestCommentModelsCollection comments;
+ private FileModel testFile1, testFile2, wordFile ;
+ private ListUserWithRoles usersWithRoles;
+ private FolderModel testFolder1;
+
+ @BeforeClass(alwaysRun = true)
+ public void dataPreparation() throws Exception
+ {
+ testUser1 = dataUser.createRandomTestUser();
+ testFolder1 = FolderModel.getRandomFolderModel();
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ }
+
+ /**
+ * Scenario 64
+ * 1. Create folder1 with WEBDAV
+ * 2. Create wordFile inside folder1 with CMIS
+ * 3. Delete wordFile content with CMIS
+ * 4. Update content using Collaborator role with CMIS
+ * 5. Append content using Manager role with WebDAV
+ * 6. Delete content that Manager added using Collaborator role with CMIS
+ * 7. Rename wordFile with WebDAV
+ * 9. Delete wordFile with WEBDAV
+ *
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "File handling using several protocols")
+ public void fileHandlingWithCollaboratorRole() throws Exception
+ {
+ String contentCollaborator = "content added by Collaborator";
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteCollaborator);
+ wordFile = FileModel.getRandomFileModel(FileType.MSWORD2007, "tasTesting");
+
+ STEP("1. Create folder1 with webdav");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFolder(testFolder1).and().assertThat().existsInRepo();
+
+ STEP("2. Create testFile1 inside folder1 using CMIS");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)).usingSite(publicSite).usingResource(testFolder1).createFile(wordFile)
+ .assertThat().existsInRepo();
+
+ STEP("3. Delete wordFile content with WebDAV");
+ cmisAPI.authenticateUser(testUser1).usingResource(wordFile).deleteContent();
+
+ STEP("4. Update content using Collaborator role with CMIS");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
+ .usingResource(wordFile).update(contentCollaborator)
+ .assertThat().contentIs(contentCollaborator);
+
+ STEP("5. Append content using Manager role with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(wordFile).update("content added by Manager").assertThat().contentIs("content added by Manager");
+
+ STEP("6. Delete content that Manager added using Collaborator role with CMIS");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator))
+ .usingResource(wordFile).deleteAllVersions(false)
+ .and().assertThat().documentHasVersion(1.2);
+
+ STEP("7. Rename wordFile with FTP");
+ ftpProtocol.authenticateUser(testUser1).usingResource(wordFile).rename("renamedFile.docx");
+
+ STEP("8. Delete file with WEBDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(wordFile).delete()
+ .assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 65
+ * 1. Create folder1 with WEBDAV
+ * 2. Create wordFile inside folder1 with CMIS
+ * 3. Delete wordFile content with CMIS
+ * 4. Update content using Contributor role with CMIS
+ * 5. Append content using Manager role with WebDAV
+ * 6. Delete content that Manager added using Collaborator role with CMIS
+ * 7. Rename wordFile with WEBDAV
+ * 8. Delete wordFile with FTP
+ *
+ * @throws Exception
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "File handling using several protocols")
+ public void fileHandlingWithContributorRole() throws Exception
+ {
+ String contentContributor = "content added by Contributor";
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite, UserRole.SiteContributor);
+ wordFile = FileModel.getRandomFileModel(FileType.MSWORD2007, "tasTesting");
+
+ STEP("1. Create folder1 with webdav");
+ webDavProtocol.authenticateUser(testUser1).usingSite(publicSite).createFolder(testFolder1).and().assertThat().existsInRepo();
+
+ STEP("2. Create testFile1 inside folder1 using CMIS");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
+ .usingResource(testFolder1).createFile(wordFile)
+ .assertThat().existsInRepo();
+
+ STEP("3. Delete wordFile content with CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(wordFile).deleteContent();
+
+ STEP("4. Update content using Contributor role with CMIS");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
+ .usingResource(wordFile).update(contentContributor)
+ .assertThat().contentIs(contentContributor);
+
+ STEP("5. Append content using Manager role with WebDAV");
+ webDavProtocol.authenticateUser(testUser1)
+ .usingResource(wordFile).update("content added by Manager")
+ .assertThat().contentIs("content added by Manager");
+
+ STEP("6. Delete content that Manager added using Contributor role with CMIS");
+ cmisAPI.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor))
+ .usingResource(wordFile).deleteAllVersions(false)
+ .and().assertThat().documentHasVersion(1.2);
+
+ STEP("7. Rename wordFile with WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(wordFile).rename("renamedFile.docx");
+
+ STEP("8. Delete file with FTP");
+ ftpProtocol.authenticateUser(testUser1).usingResource(wordFile).delete().assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 76
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates testFile1 in public site's document library using FTP
+ * 4. U1 adds comment1 for testFile1 using REST API
+ * 5. U2 gets comment1 using REST API
+ * 6. U1 updates testFile1 using WEBDAV
+ * 7. U2 gets comment1 using REST API
+ * 8. U1 deletes testFile1 using WebDAV
+ * 9. U2 can not get comment1 using REST API
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT, TestGroup.COMMENTS }, executionType = ExecutionType.REGRESSION,
+ description = "Verify comment is deleted .")
+ public void negativeScenarioWithComments() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in public site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 adds comment1 for testFile1 using REST API");
+ String newComment = "This is a new comment added by " + testUser1.getUsername();
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile1).addComment(newComment).assertThat().field("content").isNotEmpty().and().field("content").is(newComment);
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+
+ STEP("* 5. U2 gets comment1 using REST API");
+ comments = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).getNodeComments();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ comments.assertThat().entriesListContains("content", newComment);
+
+ STEP("* 6. U1 updates testFile1 using WEBDAV");
+ String newContent = "This is new content added by " + testUser1.getUsername();
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).update(newContent).and().assertThat().contentIs(newContent);
+
+ STEP("* 7. U2 gets comment1 using REST API");
+ comments = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).getNodeComments();
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ comments.assertThat().entriesListContains("content", newComment);
+
+ STEP("* 8. U1 deletes testFile1 using WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete().and().assertThat().doesNotExistInRepo();
+
+ STEP("* 9. U2 can not get comment1 using REST API");
+ comments = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).getNodeComments();
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef()));
+ }
+
+ /**
+ * Scenario 77
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates a file in public site's document library using FTP
+ * 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS
+ * 5. U2 edits the document using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify manager permission to a document in a public site - is able to edit document.")
+ public void addManagerPermissionToADocumentFromPublicSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in public site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).addAcl(testUser2, UserRole.SiteManager).then().assertThat().permissionIsSetForUser(testUser2, UserRole.SiteManager);
+
+ STEP("* 5. U2 edits the document using FTP");
+ ftpProtocol.authenticateUser(testUser2).usingSite(publicSite).usingResource(testFile1).update("new Content").assertThat().contentIs("new Content");
+ }
+
+ /**
+ * Scenario 78
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates a file in public site's document library using FTP
+ * 4. U1 applyAcl(permission) for U2 with role Site Collaborator to the document using CMIS
+ * 5. U2 edits the document using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify collaborator permission to a document in a public site - is able to edit document.")
+ public void addCollaboratorPermissionToADocumentFromPublicSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in public site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).addAcl(testUser2, UserRole.SiteCollaborator).then().assertThat().permissionIsSetForUser(testUser2, UserRole.SiteCollaborator);
+
+ STEP("* 5. U2 edits the document using FTP");
+ ftpProtocol.authenticateUser(testUser2).usingSite(publicSite).usingResource(testFile1).update("new Content").assertThat().contentIs("new Content");
+ }
+
+ /**
+ * Scenario 79
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates a file in public site's document library using FTP
+ * 4. U1 applyAcl(permission) for U2 with role Site Contributor to the document using CMIS
+ * 5. U2 edits the document using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify contributor permission to a document in a public site - is not able to edit document.")
+ public void addContributorPermissionToADocumentFromPublicSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in public site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).addAcl(testUser2, UserRole.SiteContributor).then().assertThat().permissionIsSetForUser(testUser2, UserRole.SiteContributor);
+
+ STEP("* 5. U2 edits the document using FTP");
+ ftpProtocol.authenticateUser(testUser2).usingSite(publicSite).usingResource(testFile1).update("new Content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).usingResource(testFile1).assertThat().contentIs("file1 content");
+ }
+
+ /**
+ * Scenario 80
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates a file in public site's document library using FTP
+ * 4. U1 applyAcl(permission) for U2 with role Site Consumer to the document using CMIS
+ * 5. U2 edits the document using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify consumer permission to a document in a public site - is not able to edit document.")
+ public void addConsumerPermissionToADocumentFromPublicSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public site using CMIS");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in public site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).addAcl(testUser2, UserRole.SiteConsumer).then().assertThat().permissionIsSetForUser(testUser2, UserRole.SiteConsumer);
+
+ STEP("* 5. U2 edits the document using FTP");
+ ftpProtocol.authenticateUser(testUser2).usingSite(publicSite).usingResource(testFile1).update("new Content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).usingResource(testFile1).assertThat().contentIs("file1 content");
+ }
+
+ /**
+ * Scenario 107
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a moderated site using CMIS
+ * 3. U1 creates a file in moderated site's document library using FTP
+ * 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS
+ * 5. U2 edits the document using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify manager permission to a document in a moderated site - is not able to edit document.")
+ public void addManagerPermissionToADocumentFromModeratedSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a moderated site using CMIS");
+ moderatedSite = dataSite.usingUser(testUser1).createModeratedRandomSite();
+
+ STEP("* 3. U1 creates a file in moderated site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(moderatedSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).addAcl(testUser2, UserRole.SiteManager).then().assertThat().permissionIsSetForUser(testUser2, UserRole.SiteManager);
+
+ STEP("* 5. U2 edits the document using FTP");
+ ftpProtocol.authenticateUser(testUser2).usingSite(moderatedSite).usingResource(testFile1).update("new Content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(moderatedSite).usingResource(testFile1).assertThat().contentIs("file1 content");
+ }
+
+ /**
+ * Scenario 108
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a private site using CMIS
+ * 3. U1 creates a file in private site's document library using FTP
+ * 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS
+ * 5. U2 edits the document using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION,
+ description = "Verify manager permission to a document in a private site - is not able to edit document.")
+ public void addManagerPermissionToADocumentFromPrivateSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a private site using CMIS");
+ privateSite = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("* 3. U1 creates a file in private site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(privateSite).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 applyAcl(permission) for U2 with role Site Manager to the document using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).addAcl(testUser2, UserRole.SiteManager).then().assertThat().permissionIsSetForUser(testUser2, UserRole.SiteManager);
+
+ STEP("* 5. U2 edits the document using FTP");
+ ftpProtocol.authenticateUser(testUser2).usingSite(privateSite).usingResource(testFile1).update("new Content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(privateSite).usingResource(testFile1).assertThat().contentIs("file1 content");
+ }
+
+ /**
+ * Scenario 60
+ * 1. Using CMIS creates one test user: u1
+ * 2. U1 creates testFile1 in public site using FTP
+ * 3. U1 creates testFile2 in public site using FTP
+ * 4. U1 updates testFile2 using FTP
+ * 5. Compare created date with modified date
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION, description = "Compare Modified Date")
+ public void manageModificationTimeOfFile() throws Exception
+ {
+ STEP("1. Using CMIS creates one test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates testFile1 in a public site using FTP");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile1 = new FileModel("testFile1", FileType.TEXT_PLAIN);
+ ftpProtocol.authenticateUser(testUser1).usingSite(publicSite).createFile(testFile1).assertThat().existsInRepo();
+ String modifiedDate1 = ftpProtocol.getModificationTime();
+
+ STEP("3. U1 creates testFile2 in a public site using FTP");
+ publicSite = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testFile2 = new FileModel("testFile1", FileType.TEXT_PLAIN);
+ Utility.waitToLoopTime(2);
+ ftpProtocol.usingSite(publicSite).createFile(testFile2).assertThat().existsInRepo();
+ String modifiedDate2 = ftpProtocol.getModificationTime();
+ Utility.waitToLoopTime(2, "Waiting for update");
+
+ STEP("4. U1 updates testFile2 in a public site using FTP");
+ ftpProtocol.update("test update").assertThat().contentIs("test update");
+ String updatedDate2 = ftpProtocol.getModificationTime();
+
+ STEP("5. Compare created date with modified date");
+ Assert.assertNotEquals(modifiedDate1, modifiedDate2, "Updated and modified dates are equal");
+ Assert.assertNotEquals(modifiedDate2, updatedDate2, "Modified and updated dates are equal");
+ }
+
+}
\ No newline at end of file
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationSanityTests.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationSanityTests.java
new file mode 100644
index 0000000000..c80db30096
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationSanityTests.java
@@ -0,0 +1,1108 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.mail.MessagingException;
+
+import org.alfresco.rest.model.RestCommentModel;
+import org.alfresco.rest.model.RestErrorModel;
+import org.alfresco.rest.model.RestTagModel;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.constants.UserRole;
+import org.alfresco.utility.data.RandomData;
+import org.alfresco.utility.model.*;
+import org.alfresco.utility.testrail.ExecutionType;
+import org.alfresco.utility.testrail.annotation.TestRail;
+import org.springframework.http.HttpStatus;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Created by Claudia Agache on 10/25/2016.
+ */
+public class IntegrationSanityTests extends IntegrationTest
+{
+ UserModel testUser1, testUser2, testUser3;
+ SiteModel testSitePublic, testSiteModerated, testSitePrivate, secondTestSitePublic;
+ FolderModel testFolder1, testFolder2, testFolder3;
+ FileModel testFile1, testFile2, testFile3, testFile4;
+ RestCommentModel comment;
+
+ /**
+ * Scenario 1
+ * 1. Using CMIS create two test users: u1, u2
+ * 2. U1 creates a test site using CMIS
+ * 3. Using REST API add u2 as member with Collaborator role
+ * 4. U2 creates one folder F1 using WEBDAV
+ * 5. U2 creates one file in F1 using WebDAV
+ * 6. U2 adds a comment to file using REST API
+ * 7. U1 gets comments using REST API
+ * 8. U1 updates the file content using WEBDAV. Assert with CMIS that content is updated
+ * 9. U1 updates comment using REST API
+ * 10. U2 gets comments using REST API
+ * 11. U2 deletes comment using REST API
+ * 12. U1 deletes file using FTP. Assert with CMIS that file doesn't exist in repository
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT, TestGroup.COMMENTS }, executionType = ExecutionType.SANITY,
+ description = "Verify two new users are able to manage comments on the same file.")
+ public void usersAreAbleToManageComments() throws Exception
+ {
+ STEP("* 1. Using CMIS create two test users: u1, u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. Using REST API add u2 as member with Collaborator role");
+ testUser2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2);
+
+ STEP("* 4. U2 creates one folder F1 using WEBDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser2).usingSite(testSitePublic).createFolder(testFolder1).and().assertThat().existsInWebdav();
+
+ STEP("* 5. U2 creates one file in F1 using WebDAV");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ webDavProtocol.authenticateUser(testUser2).usingResource(testFolder1).createFile(testFile1).and().assertThat().existsInWebdav();
+
+ STEP("* 6. U2 adds a comment to file using REST API");
+ comment = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).addComment("U2 comment");
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ comment.assertThat().field("content").is("U2 comment");
+
+ STEP("* 7. U1 gets comments using REST API");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingResource(testFile1).getNodeComments()
+ .assertThat().entriesListContains("content", "U2 comment");
+
+ STEP("* 8. U1 updates the file content using WEBDAV. Assert with CMIS that content is updated");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).update("file content");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFile1).assertThat().contentIs("file content");
+
+ STEP("* 9. U1 updates comment using REST API");
+ comment = restAPI.withCoreAPI().usingResource(testFile1).updateComment(comment, "U1 updated comment");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ comment.assertThat().field("content").is("U1 updated comment");
+
+ STEP("* 10. U2 gets comments using REST API");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingResource(testFile1).getNodeComments()
+ .assertThat().entriesListContains("content", "U1 updated comment");
+
+ STEP("* 11. U2 deletes comment using REST API");
+ restAPI.withCoreAPI().usingResource(testFile1).deleteComment(comment);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("* 12. U1 deletes file using FTP. Assert with CMIS that file doesn't exist in repository");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFile1).delete().assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 2
+ * 1. Using CMIS create two test users: u1, u2
+ * 2. U1 creates a test site using CMIS
+ * 3. Using CMIS add u2 as site member with Contributor role
+ * 4. U1 creates one folder F1 using FTP
+ * 5. U1 creates one file in F1 using WEBDAV
+ * 6. U2 adds file to favorites using REST API
+ * 7. U2 gets favorites using REST API. Assert that only file is favorite.
+ * 8. U1 gets favorites using REST API. Assert that U1 has his site at favorites.
+ * 9. U1 adds file to favorites using REST API
+ * 10. U1 adds folder to favorites using REST API
+ * 11. U2 remove file from favorites using REST API
+ * 12. U2 adds site to favorites using REST API
+ * 13. U2 gets favorites using REST API. Assert that only site is favorite.
+ * 14. U1 gets favorites using REST API. Assert that site, file and folder are favorites.
+ * 15. U1 deletes file using WebDAV. Assert with WebDAV that file doesn't exist in repository
+ * 16. U1 gets favorites using REST API. Assert that only site and folder are favorites.
+ * 17. U2 gets favorites using REST API. Assert that only site is favorite.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
+ description = "Verify two new users are able to manage favorites.")
+ public void usersAreAbleToManageFavorites() throws Exception
+ {
+ STEP("* 1. Using CMIS create two test users: u1, u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ restAPI.authenticateUser(dataUser.getAdminUser());
+
+ STEP("* 3. Using CMIS add u2 as site member with Contributor role");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteContributor);
+
+ STEP("* 4. U1 creates one folder F1 using FTP");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).and().assertThat().existsInRepo();
+
+ STEP("* 5. U1 creates one file in F1 using WEBDAV");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1).and().assertThat().existsInWebdav();
+
+ STEP("* 6. U2 adds file to favorites using REST API");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().addFileToFavorites(testFile1)
+ .assertThat().field("targetGuid").is(testFile1.getNodeRef().replace(";1.0", ""));
+
+ STEP("* 7. U2 gets favorites using REST API. Assert that only the file is favorite.");
+ restAPI.withCoreAPI().usingAuthUser().getFavorites()
+ .assertThat().entriesListContains("targetGuid", testFile1.getNodeRef().replace(";1.0", ""))
+ .and().paginationField("totalItems").is("1");
+
+ STEP("* 8. U1 gets favorites using REST API. Assert that U1 has his site at favorites.");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingAuthUser().getFavorites()
+ .assertThat().entriesListContains("targetGuid", testSitePublic.getGuid())
+ .and().paginationField("totalItems").is("1");
+
+ STEP("* 9. U1 adds file to favorites using REST API");
+ restAPI.withCoreAPI().usingAuthUser().addFileToFavorites(testFile1)
+ .assertThat().field("targetGuid").is(testFile1.getNodeRef().replace(";1.0", ""));
+
+ STEP("* 10. U1 adds folder to favorites using REST API");
+ restAPI.withCoreAPI().usingAuthUser().addFolderToFavorites(testFolder1)
+ .assertThat().field("targetGuid").is(testFolder1.getNodeRef());
+
+ STEP("* 11. U2 remove file from favorites using REST API");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().deleteFileFromFavorites(testFile1);
+
+ STEP("* 12. U2 adds site to favorites using REST API");
+ restAPI.withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic)
+ .assertThat().field("targetGuid").is(testSitePublic.getGuid());
+
+ STEP("* 13. U2 gets favorites using REST API. Assert that only site is favorite.");
+ restAPI.withCoreAPI().usingAuthUser().getFavorites()
+ .assertThat().entriesListDoesNotContain("targetGuid", testFile1.getNodeRef().replace(";1.0", "")).and()
+ .entriesListContains("targetGuid", testSitePublic.getGuid()).and().paginationField("totalItems").is("1");
+
+ STEP("* 14. U1 gets favorites using REST API. Assert that site, file and folder are favorites.");
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().getFavorites()
+ .assertThat().entriesListContains("targetGuid", testSitePublic.getGuid())
+ .assertThat().entriesListContains("targetGuid", testFile1.getNodeRef().replace(";1.0", ""))
+ .and().entriesListContains("targetGuid", testFolder1.getNodeRef())
+ .and().paginationField("totalItems").is("3");
+
+ STEP("* 15. U1 deletes file using WebDAV. Assert with WebDAV that file doesn't exist in repository");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete().and().assertThat().doesNotExistInWebdav();
+
+ STEP("* 16. U1 gets favorites using REST API. Assert that only site and folder are favorites.");
+ restAPI.withCoreAPI().usingAuthUser().getFavorites()
+ .assertThat().entriesListContains("targetGuid", testSitePublic.getGuid())
+ .assertThat().entriesListContains("targetGuid", testFolder1.getNodeRef())
+ .and().paginationField("totalItems").is("2");
+
+ STEP("* 17. U2 gets favorites using REST API. Assert that only site is favorite.");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().getFavorites()
+ .assertThat().entriesListContains("targetGuid", testSitePublic.getGuid())
+ .and().paginationField("totalItems").is("1");
+ }
+
+ /**
+ * Scenario 3
+ * 1. Using CMIS create two test users: u1, u2
+ * 2. U1 creates a test site using CMIS
+ * 3. Using CMIS add u2 as site member with Manager role
+ * 4. U1 creates 3 folders: F1 using FTP, F2 using WebDAV as a subfolder of F1, F3 using WEBDAV as a subfolder of F2
+ * 5. U1 creates one file in each folder using FTP and WEBDAV
+ * 6. U1 renames F2 using IMAP
+ * 7. U1 updates file1 using WebDAV
+ * 8. U1 deletes file2 using FTP
+ * 9. U1 deletes non empty folder3 using WEBDAV
+ * 10. Assert with CMIS that U2 is able to see all the above changes
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to manage files and folders.")
+ public void userIsAbleToManageFilesAndFolders() throws Exception
+ {
+ STEP("* 1. Using CMIS create two test users: u1, u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createIMAPSite();
+
+ STEP("* 3. Using CMIS add u2 as site member with Manager role");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteManager);
+
+ STEP("* 4. U1 creates 3 folders: F1 using FTP, F2 using WebDAV as a subfolder of F1, F3 using WEBDAV as a subfolder of F2. "
+ + "* 5. U1 creates one file in each folder using FTP and WEBDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFolder2 = FolderModel.getRandomFolderModel();
+ testFolder3 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ testFile2 = FileModel.getRandomFileModel(FileType.HTML);
+ testFile3 = FileModel.getRandomFileModel(FileType.MSWORD, "some content");
+
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).and().assertThat().existsInFtp();
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFolder(testFolder2).assertThat().existsInWebdav()
+ .and().createFile(testFile1).assertThat().existsInWebdav();
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder2).createFolder(testFolder3).assertThat().existsInWebdav()
+ .and().createFile(testFile2).assertThat().existsInWebdav();
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFolder3).createFile(testFile3).then().assertThat().existsInFtp();
+
+ STEP(" * 6. U1 renames F2 using IMAP");
+ imapProtocol.authenticateUser(testUser1).usingResource(testFolder2).rename("F2 rename")
+ .then().usingResource(testFolder1)
+ .assertThat().contains(new FolderModel("F2 rename"))
+ .and().assertThat().doesNotContain(testFolder2);
+
+ STEP(" * 7. U1 updates file1 using WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).update("testFile1 content.").then().assertThat().contentIs("testFile1 content.");
+
+ STEP("* 8. U1 deletes file2 using FTP");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFile2).delete().then().assertThat().doesNotExistInRepo();
+
+ STEP(" * 9. U1 deletes non empty folder3 using WEBDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder3).delete().then().assertThat().doesNotExistInWebdav();
+
+ STEP("* 10. Assert with CMIS that U2 is able to see all the above changes");
+ cmisAPI.authenticateUser(testUser2)
+ .usingResource(testFolder1).assertThat().hasChildren(testFile1)
+ .usingResource(testFile1).assertThat().contentIs("testFile1 content.")
+ .usingResource(testFile2).assertThat().doesNotExistInRepo()
+ .usingResource(testFolder3).assertThat().doesNotExistInRepo()
+ .usingResource(testFile3).assertThat().doesNotExistInRepo();
+
+ FolderModel renamedFolder = cmisAPI.usingResource(testFolder1).getFolders().get(0);
+ Assert.assertEquals(renamedFolder.getName(), "F2 rename", "User2 is able to see the renamed folder");
+ }
+
+ /**
+ * Scenario 4
+ * 1. Using CMIS create two test users: u1, u2
+ * 2. U1 creates a test site using CMIS
+ * 3. Using REST API add u2 as site member with Collaborator role
+ * 4. U2 creates file1 with using CMIS
+ * 5. U1 creates file2 from source using CMIS
+ * 6. U1 uploads file3 using FTP
+ * 7. U1 creates file4 using CMIS
+ * 8. U1 marks file1 and 3 as favorite using REST API
+ * 9. U2 marks file 1, 2, 4 as favorite using REST API
+ * 10. U2 marks site as favorite using REST API
+ * 11. U1 removes file1 from favorites using REST API
+ * 12. U2 checks file favorites using REST API. Assert that U2 gets only his favorite files.
+ * 13. U2 removes file1 from favorites using REST API
+ * 14. U2 checks file favorites using REST API. Assert that U2 gets only his favorite files.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
+ description = "Verify two new users are able to manage favorite files.")
+ public void usersAreAbleToManageFavoriteFiles() throws Exception
+ {
+ STEP("* 1. Using CMIS create two test users: u1, u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ restAPI.authenticateUser(dataUser.getAdminUser());
+ testSitePublic.setGuid(restAPI.withCoreAPI().usingSite(testSitePublic).getSite().getGuid());
+
+ STEP("* 3. Using REST API add u2 as site member with Collaborator role");
+ testUser2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2);
+
+ STEP(" * 4. U2 creates file1 with using CMIS");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ cmisAPI.authenticateUser(testUser2).usingSite(testSitePublic).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 5. U1 creates file2 from source using CMIS");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN);
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFileFromSource(testFile2, testFile1).and().refreshResource().then()
+ .assertThat().existsInRepo();
+
+ STEP(" * 6. U1 uploads file3 using FTP");
+ testFile3 = FileModel.getFileModelBasedOnTestDataFile("testUploadFile.txt");
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile3).then().assertThat().existsInRepo();
+
+ STEP("* 7. U1 creates file4 using CMIS");
+ testFile4 = FileModel.getRandomFileModel(FileType.MSWORD, "file4 content");
+ cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile4).then().assertThat().existsInRepo();
+
+ STEP("* 8. U1 marks file1 and 3 as favorite using REST API");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingAuthUser().addFileToFavorites(testFile1)
+ .assertThat().field("targetGuid").is(testFile1.getNodeRef().replace(";1.0", ""));
+ restAPI.withCoreAPI().usingAuthUser().addFileToFavorites(testFile3)
+ .assertThat().field("targetGuid").is(testFile3.getNodeRef().replace(";1.0", ""));
+
+ STEP("* 9. U2 marks file 1, 2, 4 as favorite using REST API");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().addFileToFavorites(testFile1)
+ .assertThat().field("targetGuid").is(testFile1.getNodeRef().replace(";1.0", ""));
+ restAPI.withCoreAPI().usingAuthUser().addFileToFavorites(testFile2)
+ .assertThat().field("targetGuid").is(testFile2.getNodeRef().replace(";1.0", ""));
+ restAPI.withCoreAPI().usingAuthUser().addFileToFavorites(testFile4)
+ .assertThat().field("targetGuid").is(testFile4.getNodeRef().replace(";1.0", ""));
+
+ STEP("* 10. U2 marks site as favorite using REST API");
+ restAPI.withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic)
+ .assertThat().field("targetGuid").is(testSitePublic.getGuid());
+
+ STEP("* 11. U1 removes file1 from favorites using REST API");
+ restAPI.authenticateUser(testUser1).withCoreAPI().usingAuthUser().deleteFileFromFavorites(testFile1);
+
+ STEP("* 12. U2 checks file favorites using REST API. Assert that U2 gets only his favorite files.");
+ restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser()
+ .where().targetFileExist().getFavorites().assertThat()
+ .entriesListContains("targetGuid", testFile1.getNodeRef().replace(";1.0", "")).and()
+ .entriesListContains("targetGuid", testFile2.getNodeRef().replace(";1.0", "")).and()
+ .entriesListContains("targetGuid", testFile4.getNodeRef().replace(";1.0", "")).and()
+ .paginationField("totalItems").is("3");
+
+ STEP("* 13. U2 removes file1 from favorites using REST API");
+ restAPI.withCoreAPI().usingAuthUser().deleteFileFromFavorites(testFile1);
+
+ STEP("* 14. U2 checks file favorites using REST API. Assert that U2 gets only his favorite files.");
+ restAPI.withCoreAPI().usingAuthUser()
+ .where().targetFileExist().getFavorites().assertThat()
+ .entriesListContains("targetGuid", testFile2.getNodeRef().replace(";1.0", "")).and()
+ .entriesListContains("targetGuid", testFile4.getNodeRef().replace(";1.0", "")).and()
+ .paginationField("totalItems").is("2");
+ }
+
+ /**
+ * Scenario 5
+ * 1. Using CMIS create a test user: u1
+ * 2. U1 creates a test site using CMIS
+ * 3. U1 creates 2 files in site's document library using FTP
+ * 4. U1 creates folder1 in site's document library using WebDAV
+ * 5. U1 creates another 2 files in folder1 using WEBDAV
+ * 6. U1 adds tag1, tag2 on file1, tag2 on file2 using REST API
+ * 7. U1 adds tag1 on folder1, tag3 on file3 using REST API
+ * 8. U1 gets tags and verify all tags are listed
+ * 9. U1 gets file1 tags and verify only tag1 and tag2 are listed
+ * 10. U1 deletes tag2 from file1
+ * 11. U1 deletes file3 using WebDAV
+ * 12. U1 gets tags and verify all tags are listed
+ * 13. U1 gets file1 tags and verify tag2 was removed.
+ * 14. U1 gets folder1 tags and verify only tag1 is listed.
+ * 15. U1 deletes non empty folder1 using CMIS
+ * 16. U1 gets tags and verify all tags are listed
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT, TestGroup.TAGS }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager is able to manage tags.")
+ public void siteManagerIsAbleToManageTags() throws Exception
+ {
+ STEP("* 1. Using CMIS create a test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates 2 files in site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file2 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic)
+ .createFile(testFile1).then().assertThat().existsInRepo()
+ .createFile(testFile2).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 creates folder1 in site's document library using WebDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).then().assertThat().existsInRepo();
+
+ STEP("* 5. U1 creates another 2 files in folder1 using WEBDAV");
+ testFile3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file3 content");
+ testFile4 = FileModel.getRandomFileModel(FileType.MSWORD, "file4 content");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1)
+ .createFile(testFile3).then().assertThat().existsInRepo()
+ .createFile(testFile4).then().assertThat().existsInRepo();
+
+ STEP("* 6. U1 adds tag1, tag2 on file1, tag2 on file2 using REST API");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingResource(testFile1).addTags("integration_tag1", "integration_tag2")
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().entriesListContains("tag", "integration_tag2");
+ RestTagModel tag2 = restAPI.withCoreAPI()
+ .usingResource(testFile2).addTag("integration_tag2")
+ .assertThat().field("tag").is("integration_tag2");
+
+ STEP("* 7. U1 adds tag1 on folder1, tag3 on file3 using REST API");
+ restAPI.withCoreAPI()
+ .usingResource(testFolder1).addTag("integration_tag1")
+ .assertThat().field("tag").is("integration_tag1");
+
+ restAPI.withCoreAPI()
+ .usingResource(testFile3).addTag("integration_tag3")
+ .assertThat().field("tag").is("integration_tag3");
+
+ STEP("* 8. U1 gets tags and verify all tags are listed");
+ Utility.waitToLoopTime(30);
+ restAPI.withParams("maxItems=10000").withCoreAPI().getTags()
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().entriesListContains("tag", "integration_tag2")
+ .and().entriesListContains("tag", "integration_tag3");
+
+ STEP("* 9. U1 gets file1 tags and verify only tag1 and tag2 are listed");
+ restAPI.withCoreAPI()
+ .usingResource(testFile1).getNodeTags()
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().entriesListContains("tag", "integration_tag2")
+ .and().paginationField("totalItems").is("2");
+
+ STEP("* 10. U1 deletes tag2 from file1");
+ restAPI.withCoreAPI().usingResource(testFile1).deleteTag(tag2);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("* 11. U1 deletes file3 using WebDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile3).delete().then().assertThat().doesNotExistInWebdav();
+
+ STEP("* 12. U1 gets tags and verify all tags are listed");
+ restAPI.withParams("maxItems=10000").withCoreAPI().getTags()
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().entriesListContains("tag", "integration_tag2")
+ .and().entriesListContains("tag", "integration_tag3");
+
+ STEP(" * 13. U1 gets file1 tags and verify tag2 was removed.");
+ restAPI.withCoreAPI().usingResource(testFile1).getNodeTags()
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().entriesListDoesNotContain("tag", "integration_tag2")
+ .and().paginationField("totalItems").is("1");
+
+ STEP("* 14. U1 gets folder1 tags and verify only tag1 is listed.");
+ restAPI.withCoreAPI().usingResource(testFolder1).getNodeTags()
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().paginationField("totalItems").is("1");
+
+ STEP("* 15. U1 deletes non empty folder1 using CMIS");
+ cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).deleteFolderTree().assertThat().doesNotExistInRepo();
+
+ STEP("* 16. U1 gets tags and verify all tags are listed");
+ restAPI.withParams("maxItems=10000").withCoreAPI().getTags()
+ .assertThat().entriesListContains("tag", "integration_tag1")
+ .and().entriesListContains("tag", "integration_tag2")
+ .and().entriesListContains("tag", "integration_tag3");
+ }
+
+ /**
+ * Scenario 6
+ * 1. Using CMIS create 3 test user: u1, u2, u3
+ * 2. Using CMIS U1 creates a public test site, a moderated test site and a private test site
+ * 3. Using REST API, U2 request to join the public site
+ * 4. Using REST API, U3 request to join the public site
+ * 5. Using REST API, check that u2 and u3 are added to public site with Consumer role
+ * 6. Using REST API, U2 request to join the moderated site
+ * 7. Using REST API, U3 request to join the moderated site
+ * 8. Using REST API, check that u2 and u3 requests to join the moderated site are added to site membership request list
+ * 9. Using REST API, U1 cancels the request for U3
+ * 10. Using REST API, check that u2 can't make requests to join the private site
+ * 11. Using REST API, check that only u2 request remains in site membership request list
+ * 12. Using REST API, U1 change U2 role to Collaborator in public site
+ * 13. Using REST API, get site membership information for each user
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager is able to manage site membership.")
+ public void siteManagerIsAbleToManageSiteMembership() throws Exception
+ {
+ STEP("* 1. Using CMIS create 3 test user: u1, u2, u3");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+ testUser3 = dataUser.createRandomTestUser();
+
+ STEP(" * 2. Using CMIS U1 creates a public test site, a moderated test site and a private test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+ testSitePrivate = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("* 3. Using REST API, U2 request to join the public site");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSitePublic);
+
+ STEP("* 4. Using REST API, U3 request to join the public site");
+ restAPI.authenticateUser(testUser3).withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSitePublic);
+
+ STEP(" * 5. Using REST API, check that u2 and u3 are added to public site with Consumer role");
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMembers()
+ .assertThat().entriesListContains("id", testUser2.getUsername())
+ .and().entriesListContains("id", testUser3.getUsername());
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMember(testUser2)
+ .assertThat().field("role").is("SiteConsumer");
+
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMember(testUser3)
+ .assertThat().field("role").is("SiteConsumer");
+
+ STEP("* 6. Using REST API, U3 request to join the moderated site");
+ restAPI.withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 7. Using REST API, U2 request to join the moderated site");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 8. Using REST API, check that u2 and u3 requests to join the moderated site are added to site membership request list");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(testSiteModerated).getSiteMembers()
+ .assertThat().entriesListDoesNotContain("id", testUser2.getUsername())
+ .and().entriesListDoesNotContain("id", testUser3.getUsername());
+
+ restAPI.withCoreAPI()
+ .usingUser(testUser2).getSiteMembershipRequest(testSiteModerated)
+ .assertThat().field("id").is(testSiteModerated.getId());
+
+ restAPI.withCoreAPI()
+ .usingUser(testUser3).getSiteMembershipRequest(testSiteModerated)
+ .assertThat().field("id").is(testSiteModerated.getId());
+
+ STEP("* 9. Using REST API, U1 cancels the request for U3");
+ restAPI.withCoreAPI().usingUser(testUser3).deleteSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 10. Using REST API, check that u2 can't make requests to join the private site.");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSitePrivate);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND);
+
+ STEP("* 11. Using REST API, check that only u2 request remains in site membership request list");
+ restAPI.withCoreAPI()
+ .usingAuthUser().getSiteMembershipRequests()
+ .assertThat().entriesListContains("id", testSiteModerated.getId())
+ .and().paginationField("totalItems").is("1");
+
+ restAPI.authenticateUser(testUser3).withCoreAPI()
+ .usingAuthUser().getSiteMembershipRequests()
+ .assertThat().entriesListIsEmpty();
+
+ STEP("* 12. Using REST API, U1 change U2 role to Collaborator in public site");
+ testUser2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(testSitePublic).updateSiteMember(testUser2)
+ .assertThat().field("role").is(testUser2.getUserRole());
+
+ STEP("* 13. Using REST API, get site membership information for each user");
+ restAPI.withCoreAPI()
+ .usingAuthUser().getSitesMembershipInformation()
+ .assertThat().paginationField("count").is("3");
+ restAPI.withCoreAPI()
+ .usingUser(testUser2).getSitesMembershipInformation()
+ .assertThat().entriesListContains("id", testSitePublic.getId()).and()
+ .entriesListContains("role", "SiteCollaborator").and().paginationField("count").is("1");
+ restAPI.withCoreAPI()
+ .usingUser(testUser3).getSitesMembershipInformation()
+ .assertThat().entriesListContains("id", testSitePublic.getId()).and()
+ .entriesListContains("role", "SiteConsumer").and().paginationField("count").is("1");
+ }
+
+ /**
+ * Scenario 7
+ * 1. Using CMIS create 1 test user: u1
+ * 2. Using CMIS U1 creates a public site, a moderated test site and a private test site
+ * 3. Using WEBDAV, U1 adds file1 to site1
+ * 4. Using REST API, check the u1 favorites sites list
+ * 5. Using REST API, U1 removes site1 from favorites
+ * 6. Using REST API, check the u1 favorites sites list
+ * 7. Using CMIS, U1 deletes site2
+ * 8. Using REST API, check the u1 favorites sites list
+ * 9. Using REST API, U1 marks site1 as favorite
+ * 10. Using REST API, check the u1 favorites sites list
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES, TestGroup.FAVORITES }, executionType = ExecutionType.SANITY,
+ description = "Verify users are able to manage favorite sites.")
+ public void userIsAbleToManageFavoriteSites() throws Exception
+ {
+ STEP("* 1. Using CMIS create a test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("* 2. Using CMIS U1 creates a public site, a moderated test site and a private test site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+ testSitePrivate = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("* 3. Using WEBDAV, U1 adds file1 to site1");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("* 4. Using REST API, check the u1 favorites sites list");
+ restAPI.authenticateUser(testUser1)
+ .withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites().assertThat()
+ .entriesListContains("targetGuid", testSitePublic.getGuid()).and()
+ .entriesListContains("targetGuid", testSiteModerated.getGuid()).and()
+ .entriesListContains("targetGuid", testSitePrivate.getGuid()).and()
+ .paginationField("totalItems").is("3");
+
+ STEP("* 5. Using REST API, U1 removes site1 from favorites");
+ restAPI.withCoreAPI().usingAuthUser().deleteSiteFromFavorites(testSitePublic);
+
+ STEP("* 6. Using REST API, check the u1 favorites sites list");
+ restAPI.withCoreAPI().usingAuthUser()
+ .where().targetSiteExist().getFavorites().assertThat()
+ .entriesListContains("targetGuid", testSiteModerated.getGuid()).and()
+ .entriesListContains("targetGuid", testSitePrivate.getGuid()).and()
+ .paginationField("totalItems").is("2");
+
+ STEP("* 7. Using CMIS, U1 deletes site2");
+ dataSite.usingUser(testUser1).deleteSite(testSiteModerated);
+
+ STEP("* 8. Using REST API, check the u1 favorites sites list");
+ restAPI.withCoreAPI().usingAuthUser()
+ .where().targetSiteExist().getFavorites().assertThat()
+ .entriesListContains("targetGuid", testSitePrivate.getGuid()).and()
+ .paginationField("totalItems").is("1");
+
+ STEP("* 9. Using REST API, U1 marks site1 as favorite");
+ restAPI.withCoreAPI().usingAuthUser().addSiteToFavorites(testSitePublic)
+ .assertThat().field("targetGuid").is(testSitePublic.getGuid());
+
+ STEP("* 10. Using REST API, check the u1 favorites sites list");
+ restAPI.withCoreAPI().usingAuthUser().where().targetSiteExist().getFavorites().assertThat()
+ .entriesListContains("targetGuid", testSitePublic.getGuid()).and()
+ .entriesListContains("targetGuid", testSitePrivate.getGuid()).and()
+ .paginationField("totalItems").is("2");
+ }
+
+ /**
+ * Scenario 10
+ * 1. Using CMIS create 3 test user: u1, u2, u3
+ * 2. Using CMIS U1 creates a a moderated test site
+ * 3. Using REST API, U2 request to join the moderated site
+ * 4. Using REST API, U3 request to join the moderated site
+ * 5. Using REST API, check that u2 and u3 requests to join the moderated site are added to site membership request list
+ * 6. Using REST API, U1 cancels the request for U3
+ * 7. Using REST API, check that only u2 request remains in site membership request list
+ * 8. Using REST API, U1 cancels the request for U2
+ * 9. Using REST API, verify that there is no request to join left in the site membership request list.
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.SANITY,
+ description = "Verify site manager is able to cancel requests to join moderated site.")
+ public void siteManagerIsAbleToCancelSiteMembership() throws Exception
+ {
+ STEP("* 1. Using CMIS create 3 test user: u1, u2, u3");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+ testUser3 = dataUser.createRandomTestUser();
+
+ STEP("* 2. Using CMIS U1 creates a a moderated test site");
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+
+ STEP("* 3. Using REST API, U2 request to join the moderated site");
+ restAPI.authenticateUser(testUser2).withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 4. Using REST API, U3 request to join the moderated site");
+ restAPI.authenticateUser(testUser3).withCoreAPI()
+ .usingAuthUser().addSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 5. Using REST API, check that u2 and u3 requests to join the moderated site are added to site membership request list");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingUser(testUser2).getSiteMembershipRequest(testSiteModerated)
+ .assertThat().field("id").is(testSiteModerated.getId());
+ restAPI.withCoreAPI()
+ .usingUser(testUser3).getSiteMembershipRequest(testSiteModerated)
+ .assertThat().field("id").is(testSiteModerated.getId());
+
+ STEP("* 6. Using REST API, U1 cancels the request for U3");
+ restAPI.withCoreAPI()
+ .usingUser(testUser3).deleteSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 7. Using REST API, check that u3 request isn't in site membership request list");
+ restAPI.withCoreAPI()
+ .usingUser(testUser3).getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
+ .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The relationship resource"))
+ .containsSummary(testUser3.getUsername());
+
+ STEP("* 8. Using REST API, U1 cancels the request for U2");
+ restAPI.withCoreAPI()
+ .usingUser(testUser2).deleteSiteMembershipRequest(testSiteModerated);
+
+ STEP("* 9. Using REST API, check that u2 request isn't in site membership request list.");
+ restAPI.withCoreAPI()
+ .usingUser(testUser2).getSiteMembershipRequest(testSiteModerated);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError()
+ .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "The relationship resource"))
+ .containsSummary(testUser2.getUsername());
+ }
+
+ /**
+ * Scenario 11
+ * 1. Using CMIS create 2 test user: u1, u2
+ * 2. Using CMIS U1 creates 3 test sites
+ * 3. Using CMIS U1 adds U2 to site1 with "Consumer" role
+ * 4. Using CMIS U1 adds U2 to site2 with "Collaborator" role
+ * 5. Using REST API, admin adds U2 to site3 with "Manager" role
+ * 6. Using REST API, verify that site1, site2, site3 are present in the list of sites for U2
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to get site membership informations.")
+ public void userIsAbleToGetSiteMembershipInfo() throws Exception
+ {
+ STEP("* 1. Using CMIS create 2 test user: u1, u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. Using CMIS U1 creates 3 test sites");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+ testSitePrivate = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("* 3. Using CMIS U1 adds U2 to site1 with \"Consumer\" role");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteConsumer);
+
+ STEP("* 4. Using CMIS U1 adds U2 to site2 with \"Collaborator\" role");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSiteModerated, UserRole.SiteCollaborator);
+
+ STEP("* 5. Using REST API, admin adds U2 to site3 with \"Manager\" role");
+ testUser2.setUserRole(UserRole.SiteManager);
+ restAPI.authenticateUser(dataUser.getAdminUser()).withCoreAPI()
+ .usingSite(testSitePrivate).addPerson(testUser2);
+
+ STEP("* 6. Using REST API, verify that site1, site2, site3 are present in the list of sites for U2");
+ restAPI.withCoreAPI()
+ .usingUser(testUser2).getSitesMembershipInformation()
+ .assertThat().entriesListContains("id", testSitePublic.getId())
+ .and().entriesListContains("id", testSiteModerated.getId())
+ .and().entriesListContains("id", testSitePrivate.getId())
+ .and().paginationField("count").is("3");
+
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMember(testUser2)
+ .assertThat().field("role").is("SiteConsumer");
+ restAPI.withCoreAPI()
+ .usingSite(testSiteModerated).getSiteMember(testUser2)
+ .assertThat().field("role").is("SiteCollaborator");
+ restAPI.withCoreAPI()
+ .usingSite(testSitePrivate).getSiteMember(testUser2)
+ .assertThat().field("role").is("SiteManager");
+ }
+
+ /**
+ * Scenario 12
+ * 1. Using CMIS create a test user: u1
+ * 2. U1 creates a test site using CMIS
+ * 3. U1 creates a file in site's document library using WebDAV
+ * 4. U1 creates another site using CMIS
+ * 5. U1 creates a folder in site's document library using FTP
+ * 6. U1 copy file to folder using WEBDAV
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to copy file to a folder from another site.")
+ public void userIsAbleToCopyFileToAFolderFromAnotherSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create a test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in site's document library using WebDAV");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 creates another site using CMIS");
+ secondTestSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 5. U1 creates a folder in second site's document library using FTP");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser1).usingSite(secondTestSitePublic).createFolder(testFolder1).then().assertThat().existsInRepo();
+
+ STEP("* 6. U1 copy file to folder using WEBDAV");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).copyTo(testFolder1).assertThat().existsInRepo();
+ }
+
+ /**
+ * Scenario 13
+ * 1. Using CMIS create a test user: u1
+ * 2. U1 creates a test site using CMIS
+ * 3. U1 creates a file in site's document library using FTP
+ * 4. U1 creates another site using CMIS
+ * 5. U1 creates a folder in site's document library using WebDAV
+ * 6. U1 moves file to folder using FTP
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to move file to a folder from another site.")
+ public void userIsAbleToMoveFileToAFolderFromAnotherSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create a test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U1 creates another site using CMIS");
+ secondTestSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 5. U1 creates a folder in second site's document library using WebDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser1).usingSite(secondTestSitePublic).createFolder(testFolder1).then().assertThat().existsInRepo();
+
+ STEP("* 6. U1 moves file to folder using FTP");
+ ftpProtocol.authenticateUser(testUser1).usingResource(testFile1).moveTo(testFolder1).assertThat().existsInRepo();
+ }
+
+ /**
+ * Scenario 14
+ * 1. Using CMIS create a test user: u1
+ * 2. U1 creates a public test site, a moderated test site and a private test site using CMIS
+ * 3. U1 gets each site with REST API: public, moderated and private sites are listed
+ * 4. U1 deletes moderated site using CMIS
+ * 5. U1 gets each site with REST API: public and private sites are listed
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to get created sites with different visibility.")
+ public void userIsAbleToGetSitesWithDifferentVisibility() throws Exception
+ {
+ STEP("* 1. Using CMIS create a test user: u1");
+ testUser1 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public test site, a moderated test site and a private test site using CMIS ");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite();
+ testSitePrivate = dataSite.usingUser(testUser1).createPrivateRandomSite();
+
+ STEP("* 3. U1 gets each site with REST API: public, moderated and private sites are listed");
+ restAPI.authenticateUser(testUser1);
+
+ List createdSites = new ArrayList();
+ createdSites.add(testSitePublic);
+ createdSites.add(testSiteModerated);
+ createdSites.add(testSitePrivate);
+
+ for(SiteModel site : createdSites)
+ {
+ restAPI.withCoreAPI()
+ .usingSite(site).getSite()
+ .assertThat().field("id").is(site.getId())
+ .and().field("title").is(site.getTitle());
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ }
+
+ STEP("* 4. U1 deletes moderated site using CMIS");
+ dataSite.usingUser(testUser1).deleteSite(testSiteModerated);
+
+ STEP("* 5. U1 gets each site with REST API: public and private sites are listed");
+ restAPI.withParams("maxItems=10000").withCoreAPI().getSites()
+ .assertThat().entriesListContains("id", testSitePublic.getId())
+ .assertThat().entriesListContains("id", testSitePrivate.getId())
+ .assertThat().entriesListDoesNotContain("id", testSiteModerated.getId());
+ }
+
+ /**
+ * Scenario 15
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 creates a file in public site's document library using FTP
+ * 4. U2 creates a private site using CMIS
+ * 5. U2 creates a folder in public site's document library using WebDAV
+ * 6. U1 copies the file in private site's document library using WEBDAV
+ * 7. Using WEBDAV, verify that file was not copied
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.SANITY,
+ description = "Verify uninvited user is not able to copy document to a private site.")
+ public void userIsNotAbleToCopyAFileToAPrivateSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 creates a file in public site's document library using FTP");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U2 creates a private site using CMIS");
+ testSitePrivate = dataSite.usingUser(testUser2).createPrivateRandomSite();
+
+ STEP("* 5. U2 creates a folder in public site's document library using WebDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser2).usingSite(testSitePrivate).createFolder(testFolder1).then().assertThat().existsInRepo();
+
+ STEP("* 6. U1 copies the file in private site's document library using WEBDAV"
+ + "* 7. Using WEBDAV, verify that file was not copied");
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).copyTo(testFolder1).assertThat().doesNotExistInRepo();
+ }
+
+ /**
+ * Scenario 16
+ * 1. Using CMIS create two users: u1 and u2
+ * 2. U1 creates a public site using CMIS
+ * 3. U1 adds U2 to site with "Consumer" role using CMIS
+ * 4. Using REST API, verify membership information for u2 on public site
+ * 5. Using REST API, U1 change U2 role to Collaborator in public site
+ * 6. Using REST API, verify membership information for u2 on public site
+ * 7. Using REST API, U1 remove U2 from public site
+ * 8. Using REST API, verify that u2 isn't member of u1 public site
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to get user membership information.")
+ public void userIsAbleToGetASiteMember() throws Exception
+ {
+ STEP("* 1: Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2: U1 creates a public site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. U1 adds U2 to site with \"Consumer\" role using CMIS");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteConsumer);
+
+ STEP("* 4. Using REST API, verify membership information for u2 on public site");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(testSitePublic).getSiteMember(testUser2)
+ .assertThat().field("role").is("SiteConsumer");
+
+ STEP("* 5. Using REST API, U1 change U2 role to Collaborator in public site");
+ testUser2.setUserRole(UserRole.SiteCollaborator);
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).updateSiteMember(testUser2)
+ .assertThat().field("role").is(testUser2.getUserRole());
+
+ STEP("* 6. Using REST API, verify membership information for u2 on public site");
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMember(testUser2)
+ .assertThat().field("role").is("SiteCollaborator");
+
+ STEP("* 7. Using REST API, U1 remove U2 from public site");
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).deleteSiteMember(testUser2);
+ restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT);
+
+ STEP("* 8. Using REST API, verify that u2 isn't member of u1 public site");
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMember(testUser2);
+ restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND)
+ .assertLastError().containsSummary(String.format("The relationship resource was not found for the entity with id: %s and a relationship id of %s", testUser2.getUsername(), testSitePublic.getId()));
+ }
+
+ /**
+ * Scenario 17
+ * 1. Using CMIS create 3 test user: u1, u2, u3
+ * 2. Using CMIS U1 creates a public site
+ * 3. Using CMIS U1 adds U2 to site with "Contributor" role
+ * 4. Using CMIS U1 adds U3 to site with "Collaborator" role
+ * 5. Using REST API, verify the information related to site's containers and members
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.SITES }, executionType = ExecutionType.SANITY,
+ description = "Verify user is able to get site membership informations.")
+ public void userIsAbleToGetSite() throws Exception
+ {
+ STEP("* 1. Using CMIS create 3 test user: u1, u2, u3");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+ testUser3 = dataUser.createRandomTestUser();
+
+ STEP("* 2. Using CMIS U1 creates a public site");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+
+ STEP("* 3. Using CMIS U1 adds U2 to site with \"Contributor\" role");
+ dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteContributor);
+
+ STEP("* 4. Using CMIS U1 adds U3 to site with \"Collaborator\" role");
+ dataUser.usingUser(testUser1).addUserToSite(testUser3, testSitePublic, UserRole.SiteCollaborator);
+
+ STEP("* 5. Using REST API, verify the information related to site's containers and members");
+ restAPI.authenticateUser(testUser1).withCoreAPI()
+ .usingSite(testSitePublic).getSite()
+ .assertThat().field("visibility").is("PUBLIC")
+ .and().field("id").is(testSitePublic.getId());
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteMembers()
+ .assertThat().paginationField("count").is("3");
+ restAPI.withCoreAPI()
+ .usingSite(testSitePublic).getSiteContainers()
+ .assertThat().entriesListContains("folderId", "documentLibrary")
+ .and().paginationField("totalItems").is("1");
+ }
+
+ /**
+ * Scenario 18
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a public test site and U2 a moderated test site using CMIS
+ * 3. U1 creates a folder with a file in public site's document library using WEBDAV
+ * 4. U2 creates a folder in moderated site's document library using FTP
+ * 5. U1 tries to copy the folder to moderated site using WebDAV
+ * 6. Verify folder is not copied. U1 is not authorized to access the moderated site
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.SANITY,
+ description = "Verify user is not able to copy folder to a moderated site if it is not a member of that site.")
+ public void copyFolderToModeratedSiteByUninvitedUser() throws Exception
+ {
+ STEP("* 1. Using CMIS create two users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("* 2. U1 creates a public test site and U2 a moderated test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testSiteModerated = dataSite.usingUser(testUser2).createModeratedRandomSite();
+
+ STEP("* 3. U1 creates a folder with a file in public site's document library using WEBDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInWebdav()
+ .then().usingResource(testFolder1).createFile(testFile1).then().assertThat().existsInRepo();
+
+ STEP("* 4. U2 creates a folder in moderated site's document library using FTP");
+ testFolder2 = FolderModel.getRandomFolderModel();
+ ftpProtocol.authenticateUser(testUser2).usingSite(testSiteModerated).createFolder(testFolder2).assertThat().existsInRepo();
+
+ STEP("* 5. U1 tries to copy the folder to moderated site using WebDAV"
+ + "* 6. Verify folder is not copied. U1 is not authorized to access the moderated site");
+ testFolder2.setProtocolLocation(webDavProtocol.getPrefixSpace() + testFolder2.getCmisLocation());
+ webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).copyTo(testFolder2).assertThat().doesNotExistInRepo()
+ .and().assertThat().doesNotExistInWebdav();
+ }
+
+ /**
+ * Scenario 20
+ * 1. Using CMIS create 2 test users: u1 and u2
+ * 2. U1 creates a public test site and U2 a private test site using CMIS
+ * 3. U1 creates a file in public site's document library using WEBDAV
+ * 4. U2 creates a folder in private site's document library using WebDAV
+ * 5. U1 tries to move his file to folder from U2 private site using IMAP
+ * 6. Verify file is not moved. U1 is not authorized to access the private site
+ */
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.SANITY }, expectedExceptions = MessagingException.class)
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.SANITY,
+ description = "Verify user is not able to move file to a private site if he is not a member of that site.")
+ public void moveFileToPrivateSiteByUninvitedUser() throws Exception
+ {
+ STEP("1. Using CMIS create 2 test users: u1 and u2");
+ testUser1 = dataUser.createRandomTestUser();
+ testUser2 = dataUser.createRandomTestUser();
+
+ STEP("2. U1 creates a public test site and U2 a private test site using CMIS");
+ testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite();
+ testSitePrivate = dataSite.usingUser(testUser2).createPrivateRandomSite();
+
+ STEP("3. U1 creates a file in public site's document library using WEBDAV");
+ testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content");
+ webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1).assertThat().existsInRepo();
+
+ STEP("4. U2 creates a folder in private site's document library using WebDAV");
+ testFolder1 = FolderModel.getRandomFolderModel();
+ webDavProtocol.authenticateUser(testUser2).usingSite(testSitePrivate).createFolder(testFolder1).assertThat().existsInRepo();
+
+ STEP("5. U1 tries to move his file to folder from U2 private site using IMAP. 6. Verify file is not moved. U1 is not authorized to access the private site ");
+ testFolder1.setProtocolLocation(testFolder1.getCmisLocation());
+ imapProtocol.authenticateUser(testUser1).usingResource(testFile1).moveMessageTo(testFolder1).assertThat().doesNotContainMessages(testFile1);
+ }
+}
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationTest.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationTest.java
new file mode 100644
index 0000000000..4765948b5a
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationTest.java
@@ -0,0 +1,106 @@
+package org.alfresco.tas.integration;
+
+import java.lang.reflect.Method;
+
+import org.alfresco.cmis.CmisProperties;
+import org.alfresco.cmis.CmisWrapper;
+import org.alfresco.dataprep.WorkflowService;
+import org.alfresco.email.EmailProperties;
+import org.alfresco.email.ImapWrapper;
+import org.alfresco.email.SmtpWrapper;
+import org.alfresco.ftp.FTPWrapper;
+import org.alfresco.rest.core.RestProperties;
+import org.alfresco.rest.core.RestWrapper;
+import org.alfresco.utility.LogFactory;
+import org.alfresco.utility.data.DataContent;
+import org.alfresco.utility.data.DataGroup;
+import org.alfresco.utility.data.DataSite;
+import org.alfresco.utility.data.DataUser;
+import org.alfresco.utility.data.DataWorkflow;
+import org.alfresco.utility.extension.ExtentionPointTestUtility;
+import org.alfresco.utility.network.ServerHealth;
+import org.alfresco.webdav.WebDavWrapper;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+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-integration-context.xml")
+public abstract class IntegrationTest extends AbstractTestNGSpringContextTests
+{
+ private static Logger LOG = LogFactory.getLogger();
+
+ @Autowired
+ protected DataUser dataUser;
+
+ @Autowired
+ protected DataSite dataSite;
+
+ @Autowired
+ protected DataContent dataContent;
+
+ @Autowired
+ protected DataGroup dataGroup;
+
+ @Autowired
+ protected DataWorkflow dataWorkflow;
+
+ @Autowired
+ protected WorkflowService workflow;
+
+ @Autowired
+ protected FTPWrapper ftpProtocol;
+
+ @Autowired
+ protected WebDavWrapper webDavProtocol;
+
+ @Autowired
+ protected CmisWrapper cmisAPI;
+
+ @Autowired
+ protected CmisProperties cmisProperties;
+
+ @Autowired
+ protected ImapWrapper imapProtocol;
+
+ @Autowired
+ protected RestWrapper restAPI;
+
+ @Autowired
+ protected ServerHealth serverHealth;
+
+ @Autowired
+ protected RestProperties restProperties;
+
+ @Autowired
+ protected ExtentionPointTestUtility extentionPointTestUtility;
+
+ @Autowired
+ protected SmtpWrapper smtpProtocol;
+
+ @Autowired
+ EmailProperties emailProperties;
+
+ @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()));
+ }
+
+}
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationWithAosTests.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationWithAosTests.java
new file mode 100644
index 0000000000..c91e948b28
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationWithAosTests.java
@@ -0,0 +1,88 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.json.JsonObject;
+
+import org.alfresco.rest.core.JsonBodyGenerator;
+import org.alfresco.rest.core.RestRequest;
+import org.alfresco.rest.model.RestHtmlResponse;
+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.commons.codec.binary.Base64;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.testng.annotations.Test;
+
+/**
+ * @author Catalin Gornea
+ */
+public class IntegrationWithAosTests extends IntegrationTest
+{
+ @Bug(id = "REPO-2096", status = Status.FIXED)
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.AOS, TestGroup.FULL, TestGroup.SSO })
+ @TestRail(section = { TestGroup.INTEGRATION,
+ TestGroup.AOS }, executionType = ExecutionType.REGRESSION, description = "Security check for AOS Protocol with External Authentification - MNT-17474")
+ public void aosCSRFVulnerabilityInSSOEnvironment() throws Exception
+ {
+ STEP("1. Post call using RestAPI for specific AOS Security issue");
+ UserModel adminUser = dataUser.getAdminUser();
+ Map headers = new HashMap();
+ String authCookie = String.format("%s:%s", adminUser.getUsername(), adminUser.getPassword());
+ String authCookieEncoded = new String(Base64.encodeBase64(authCookie.getBytes()));
+ headers.put("Authorization", String.format("Basic %s", authCookieEncoded));
+
+ restAPI.configureRequestSpec().addHeaders(headers);
+ JsonObject postBody = JsonBodyGenerator.defineJSON().add("method", "create url-directories:6.0.2.8164")
+ .add("urldirs", "[[url=ExploitedMNT17474;meta_info=[]]]").build();
+ restAPI.authenticateUser(adminUser).usingContentType(ContentType.URLENC).withAosAPI();
+ RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody.toString(), "_vti_bin/_vti_aut/author.dll");
+ restAPI.process(request);
+ restAPI.assertStatusCodeIs(HttpStatus.BAD_REQUEST);
+ }
+
+ @Bug(id = "REPO-2172", status = Status.FIXED)
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.AOS, TestGroup.FULL, TestGroup.SSO })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.AOS },
+ executionType = ExecutionType.REGRESSION, description = "Non domain user can login to aos through Kerberos successfully.")
+ public void nonDomainKerberosUserCanLoginSuccessfulInAos() throws Exception {
+
+ STEP("1. Perform a GET request of aos using a non-domain kerberos user");
+ String webDavUrl = "alfresco/aos";
+
+ RestAssured.basePath = "";
+ restAPI.configureRequestSpec().setBasePath(RestAssured.basePath);
+ RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, webDavUrl);
+ RestHtmlResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).processHtmlResponse(request);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertPathInHtmlBodyEquals("html.body.table.tr[1].td[0].text()", "Shared");
+ response.assertPathInHtmlBodyEquals("html.body.table.tr[2].td[0].text()", "Imap Attachments");
+ }
+
+ @Bug(id = "REPO-2172", status = Status.FIXED)
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.WEBDAV, TestGroup.FULL, TestGroup.SSO })
+ @TestRail(section = { TestGroup.INTEGRATION, TestGroup.WEBDAV },
+ executionType = ExecutionType.REGRESSION, description = "Non domain user can login to webdav through Kerberos successfully.")
+ public void nonDomainKerberosUserCanLoginSuccessfulInWebDav() throws Exception {
+
+ STEP("1. Perform a GET request of webdav using a non-domain kerberos user");
+ String webDavUrl = "alfresco/webdav";
+
+ RestAssured.basePath = "";
+ restAPI.configureRequestSpec().setBasePath(RestAssured.basePath);
+ RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, webDavUrl);
+ RestHtmlResponse response = restAPI.authenticateUser(dataUser.getAdminUser()).processHtmlResponse(request);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertPathInHtmlBodyEquals("html.body.table.tr.td[0].text()", "Directory listing for /");
+ response.assertPathInHtmlBodyEquals("html.body.table.tr.td.find{it.@class=='textData'}[0].text()", "Shared");
+ }
+}
diff --git a/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationWithCmisTests.java b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationWithCmisTests.java
new file mode 100644
index 0000000000..b3a5be9a8f
--- /dev/null
+++ b/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationWithCmisTests.java
@@ -0,0 +1,189 @@
+package org.alfresco.tas.integration;
+
+import static org.alfresco.utility.report.log.Step.STEP;
+
+import io.restassured.RestAssured;
+import java.util.HashMap;
+
+import org.alfresco.rest.core.JsonBodyGenerator;
+import org.alfresco.rest.core.RestRequest;
+import org.alfresco.rest.core.RestResponse;
+import org.alfresco.rest.model.RestNodeModel;
+import org.alfresco.rest.model.RestRenditionInfoModel;
+import org.alfresco.utility.Utility;
+import org.alfresco.utility.exception.DataPreparationException;
+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.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+public class IntegrationWithCmisTests extends IntegrationTest
+{
+ private UserModel user;
+ private SiteModel site;
+
+ @BeforeClass(alwaysRun = true)
+ public void createUserAndSite() throws DataPreparationException
+ {
+ user = dataUser.createRandomTestUser();
+ site = dataSite.usingUser(user).createPublicRandomSite();
+ }
+
+// @Test(groups = { TestGroup.INTEGRATION, TestGroup.CMIS, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION,
+ TestGroup.CMIS }, executionType = ExecutionType.REGRESSION, description = "Verify getChildren action for a large number of files from CMIS returns only unique values with few retries")
+ public void verifyGetChildrenReturnsUniqueValues() throws Exception
+ {
+ STEP("1. Create user, site, folder.");
+ FolderModel folder = FolderModel.getRandomFolderModel();
+ folder = dataContent.usingUser(user).usingSite(site).createFolder(folder);
+
+ STEP("2. Create 5000 files in folder using webscript");
+ int totalFiles = 5000;
+ String fileCreationWebScript = "alfresco/s/api/model/filefolder/load";
+ HashMap input = new HashMap();
+ input.put("folderPath", folder.getCmisLocation());
+ input.put("fileCount", String.valueOf(totalFiles));
+ String postBody = JsonBodyGenerator.keyValueJson(input);
+
+ RestAssured.basePath = "";
+ restAPI.configureRequestSpec().setBasePath(RestAssured.basePath);
+ RestRequest request = RestRequest.requestWithBody(HttpMethod.POST, postBody, fileCreationWebScript);
+ RestResponse response = restAPI.authenticateUser(user).process(request);
+ Assert.assertEquals(response.getResponse().getStatusCode(), HttpStatus.OK.value());
+
+ STEP("3. Verify getChildren from CMIS returns unique values");
+ cmisAPI.authenticateUser(user).usingSite(site).usingResource(folder);
+ for (int i = 1; i <= 20; i++)
+ {
+ System.out.println(String.format("Try no: %d", i));
+ cmisAPI.usingResource(folder).assertThat().hasUniqueChildren(totalFiles);
+ }
+ }
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CMIS, TestGroup.CORE })
+ @TestRail(section = { TestGroup.INTEGRATION,
+ TestGroup.CMIS }, executionType = ExecutionType.REGRESSION, description = "Verify content and thumbnail of TIF files are retrieved by CMIS ")
+ @Bug(id = "REPO-2042", description = "Should fail only on MAC OS System and Linux")
+ public void verifyContentAndThumbnailForTifFile() throws Exception
+ {
+ STEP("1. Create user, site and a folder ");
+ FolderModel folder = FolderModel.getRandomFolderModel();
+ folder = dataContent.usingUser(user).usingSite(site).createFolder(folder);
+
+ STEP("2. Upload existing TIF file using RESTAPI");
+ restAPI.authenticateUser(user).configureRequestSpec().addMultiPart("filedata", Utility.getResourceTestDataFile("my-file.tif"));
+
+ RestNodeModel fileNode = restAPI.authenticateUser(user).withCoreAPI().usingNode(folder).createNode();
+ restAPI.assertStatusCodeIs(HttpStatus.CREATED);
+ FileModel file = new FileModel("my-file.tif");
+ file.setCmisLocation(folder.getCmisLocation() + "/my-file.tif");
+ file.setNodeRef(fileNode.getId());
+
+ STEP("3. Create thumbnail and content of TIF files using file");
+ restAPI.withCoreAPI().usingNode(file).createNodeRendition("pdf");
+ restAPI.assertStatusCodeIs(HttpStatus.ACCEPTED);
+ restAPI.withCoreAPI().usingNode(file).createNodeRendition("doclib");
+ restAPI.assertStatusCodeIs(HttpStatus.ACCEPTED);
+
+ STEP("4. Verify thumbnail and content of TIF files are created using RESTAPI");
+ cmisAPI.authenticateUser(user).usingSite(site).usingResource(folder).usingResource(file).assertThat().contentContains("Adobe Photoshop CC 2015");
+ RestRenditionInfoModel renditionInfo = restAPI.withCoreAPI().usingNode(file).getNodeRendition("pdf");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ renditionInfo.assertThat().field("status").is("CREATED");
+ renditionInfo = restAPI.withCoreAPI().usingNode(file).getNodeRendition("doclib");
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ renditionInfo.assertThat().field("status").is("CREATED");
+ }
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CMIS, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION,
+ TestGroup.CMIS }, executionType = ExecutionType.REGRESSION, description = "Verify getChildren action for a large number of files from CMIS returns only unique values with few retries")
+ public void verifyContentDispositionForContentThatAreWhiteListed() throws Exception
+ {
+
+ STEP("1. Create a .pdf and a .html file in the Shared folder in CMIS");
+ FolderModel sharedFolder = FolderModel.getSharedFolderModel();
+ FileModel pdfFile = FileModel.getRandomFileModel(FileType.PDF);
+ FileModel htmlFile = FileModel.getRandomFileModel(FileType.HTML);
+
+ STEP("2. Upload the .pdf file and verify the reponse header adding the download=inline/attachement parameters (accepted both).");
+ cmisAPI.authenticateUser(user).usingResource(sharedFolder).createFile(pdfFile);
+
+ RestResponse response = restAPI.authenticateUser(user).withCMISApi().getRootObjectByLocation(pdfFile);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertThat().header("Content-Disposition", String.format("inline; filename=%s", pdfFile.getName()));
+
+ response = restAPI.authenticateUser(user).withCMISApi().usingParams("download=inline").getRootObjectByLocation(pdfFile);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertThat().header("Content-Disposition", String.format("inline; filename=%s", pdfFile.getName()));
+
+ response = restAPI.authenticateUser(user).withCMISApi().usingParams("download=attachment").getRootObjectByLocation(pdfFile);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", pdfFile.getName()));
+
+ STEP("3. Upload the .html file and verify the reponse header adding the download=inline/attachement parameters (accepted only attachment) .");
+ cmisAPI.usingResource(sharedFolder).createFile(htmlFile);
+
+ response = restAPI.authenticateUser(user).withCMISApi().getRootObjectByLocation(htmlFile);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", htmlFile.getName()));
+
+ response = restAPI.authenticateUser(user).withCMISApi().usingParams("download=attachment").getRootObjectByLocation(htmlFile);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", htmlFile.getName()));
+
+ response = restAPI.authenticateUser(user).withCMISApi().usingParams("download=inline").getRootObjectByLocation(htmlFile);
+ restAPI.assertStatusCodeIs(HttpStatus.OK);
+ response.assertThat().header("Content-Disposition", String.format("attachment; filename=%s", htmlFile.getName()));
+ }
+
+ @Test(groups = { TestGroup.INTEGRATION, TestGroup.CMIS, TestGroup.FULL })
+ @TestRail(section = { TestGroup.INTEGRATION,
+ TestGroup.CMIS }, executionType = ExecutionType.SANITY, description = "Verify that alfresco returns the correct encoding for files created via CMIS.")
+ public void verifyFileEncodingUsingCMIS() throws Exception
+ {
+ STEP("1. Create a folder, two text file with specific encoding content and define the expected encoding.");
+ FileModel utf8File = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, " ∮ E⋅da = Q");
+ FileModel iso8859File = FileModel.getRandomFileModel(FileType.TEXT_PLAIN,
+ "aegif Mind Share Leader Generating New Paradigms by aegif corporation Test html