Alex Mukha
2019-11-21 15:08:58 +00:00
committed by GitHub
parent 1ff57b4140
commit 8411ce5aa2
330 changed files with 57943 additions and 12 deletions

View File

@@ -14,10 +14,6 @@ cache:
env: env:
global: global:
- VERSION_EDITION=Community - 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: branches:
only: only:
@@ -29,13 +25,49 @@ matrix:
# only on master and if it is not a PR # only on master and if it is not a PR
if: fork = false AND branch = master AND type != pull_request if: fork = false AND branch = master AND type != pull_request
install: 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: script:
# Download the latest version of WhiteSource Unified Agent # Download the latest version of WhiteSource Unified Agent
- curl -LJO https://github.com/whitesource/unified-agent-distribution/raw/master/standAlone/wss-unified-agent.jar - curl -LJO https://github.com/whitesource/unified-agent-distribution/raw/master/standAlone/wss-unified-agent.jar
# Run WhiteSource Unified Agent # Run WhiteSource Unified Agent
- java -jar wss-unified-agent.jar -apiKey ${WHITESOURCE_API_KEY} -c .wss-unified-agent.config -d ./war - java -jar wss-unified-agent.jar -apiKey ${WHITESOURCE_API_KEY} -c .wss-unified-agent.config -d ./war
- name: "Build packaging" - name: "REST API TAS tests"
install: skip 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: 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

View File

@@ -54,8 +54,8 @@ services:
- 8082:8080 - 8082:8080
- 8000:8000 - 8000:8000
- 143:1143 - 143:1143
- "21:1221" - 21:1221
- "30000-30099:30000-30099" - 30000-30099:30000-30099
alfresco-pdf-renderer: alfresco-pdf-renderer:
image: alfresco/alfresco-pdf-renderer:${TRANSFORMERS_TAG} image: alfresco/alfresco-pdf-renderer:${TRANSFORMERS_TAG}
@@ -106,8 +106,6 @@ services:
- POSTGRES_PASSWORD=alfresco - POSTGRES_PASSWORD=alfresco
- POSTGRES_USER=alfresco - POSTGRES_USER=alfresco
- POSTGRES_DB=alfresco - POSTGRES_DB=alfresco
ports:
- 5432:5432
solr6: solr6:
image: alfresco/alfresco-search-services:${SOLR6_TAG} image: alfresco/alfresco-search-services:${SOLR6_TAG}

15
pom.xml
View File

@@ -37,6 +37,12 @@
<module>docker-alfresco</module> <module>docker-alfresco</module>
</modules> </modules>
</profile> </profile>
<profile>
<id>all-tas-tests</id>
<modules>
<module>tests</module>
</modules>
</profile>
</profiles> </profiles>
<scm> <scm>
@@ -101,6 +107,15 @@
<dependency.postgresql.version>42.2.6</dependency.postgresql.version> <dependency.postgresql.version>42.2.6</dependency.postgresql.version>
<dependency.tas-utility.version>3.0.14</dependency.tas-utility.version>
<dependency.rest-assured.version>3.3.0</dependency.rest-assured.version>
<dependency.javax.json.version>1.0.4</dependency.javax.json.version>
<dependency.tas-restapi.version>1.15</dependency.tas-restapi.version>
<dependency.tas-cmis.version>1.5</dependency.tas-cmis.version>
<dependency.tas-email.version>1.1</dependency.tas-email.version>
<dependency.tas-webdav.version>1.0</dependency.tas-webdav.version>
<dependency.tas-ftp.version>1.0</dependency.tas-ftp.version>
<dependency.tas-dataprep.version>2.2</dependency.tas-dataprep.version>
</properties> </properties>
<dependencyManagement> <dependencyManagement>

4
tests/environment/.env Normal file
View File

@@ -0,0 +1,4 @@
TRANSFORMERS_TAG=2.1.0
SOLR6_TAG=1.4.0
POSTGRES_TAG=11.4
ACTIVEMQ_TAG=5.15.8

View File

@@ -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

View File

@@ -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

86
tests/pom.xml Normal file
View File

@@ -0,0 +1,86 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>acs-community-packaging</artifactId>
<version>6.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modules>
<module>tas-restapi</module>
<module>tas-cmis</module>
<module>tas-email</module>
<module>tas-webdav</module>
<module>tas-integration</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>utility</artifactId>
<version>${dependency.tas-utility.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${dependency.rest-assured.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>${dependency.javax.json.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>restapi</artifactId>
<version>${dependency.tas-restapi.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>cmis</artifactId>
<version>${dependency.tas-cmis.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>email</artifactId>
<version>${dependency.tas-email.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>webdav</artifactId>
<version>${dependency.tas-webdav.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>ftp</artifactId>
<version>${dependency.tas-ftp.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.alfresco.test</groupId>
<artifactId>dataprep</artifactId>
<version>${dependency.tas-dataprep.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${dependency.spring.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

22
tests/scripts/start-compose.sh Executable file
View File

@@ -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

19
tests/scripts/stop-compose.sh Executable file
View File

@@ -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

View File

@@ -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

66
tests/tas-cmis/pom.xml Normal file
View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-cmis-test</artifactId>
<name>content-repository-community-cmis-test</name>
<version>6.3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<developers>
<developer>
<name>Paul Brodner</name>
<roles>
<role>Test Automation Architect</role>
</roles>
</developer>
</developers>
<properties>
<suiteXmlFile>${project.basedir}/src/test/resources/cmis-suite.xml</suiteXmlFile>
</properties>
<dependencies>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>cmis</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<argLine>
--illegal-access=warn
</argLine>
</configuration>
</plugin>
<!-- Build only test jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,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();
}
}

View File

@@ -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();
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1 @@
Sp23xfcYhUBYpsXuPFzn8nVQ

View File

@@ -0,0 +1 @@
tas

66
tests/tas-email/pom.xml Normal file
View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-email-test</artifactId>
<name>content-repository-community-email-test</name>
<version>6.3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<developers>
<developer>
<name>Paul Brodner</name>
<roles>
<role>Test Automation Architect</role>
</roles>
</developer>
</developers>
<properties>
<suiteXmlFile>${project.basedir}/src/test/resources/email-suite.xml</suiteXmlFile>
</properties>
<dependencies>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>email</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<argLine>
--illegal-access=warn
</argLine>
</configuration>
</plugin>
<!-- Build only test jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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()));
}
}

View File

@@ -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);
}
}

View File

@@ -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"));
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

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

View File

@@ -0,0 +1,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=<username>
# testManagement.apiKey=<api-key>
# testManagement.project=<id-of-your-project
# testManagement.testRun=<test-run-name>
# testManagement.includeOnlyTestCasesExecuted=true #if you want to include in your run ONLY the test cases that you run, then set this value to false
# testManagement.rateLimitInSeconds=1 #is the default rate limit after what minimum time, should we upload the next request. http://docs.gurock.com/testrail-api2/introduction #Rate Limit
# testManagement.suiteId=23 (the id of the Master suite)
# ------------------------------------------------------
testManagement.enabled=false
testManagement.endPoint=
testManagement.username=
testManagement.apiKey=
testManagement.project=7
testManagement.includeOnlyTestCasesExecuted=true
testManagement.rateLimitInSeconds=1
testManagement.testRun=MyTestRunInTestRail
testManagement.suiteId=12
# The location of the reports path
reports.path=./target/reports
#
# Database Section
# You should provide here the database URL, that can be a differed server as alfresco.
# https://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html
#
# Current supported db.url:
#
# MySQL:
# db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
#
# PostgreSQL:
# db.url = jdbc:postgresql://<your-DB-IP>:3306/alfresco
#
# Oracle:
# db.url = jdbc:oracle://<your-DB-IP>:3306/alfresco
#
# MariaDB:
# db.url = jdbc:mariadb://<your-DB-IP>:3306/alfresco
#
db.url = jdbc:mysql://${alfresco.server}:3306/alfresco
db.username = alfresco
db.password = alfresco

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAIL API" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"/>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"/>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"/>
</listeners>
<test name="Email tests">
<packages>
<package name="org.alfresco.email.*"/>
</packages>
</test>
</suite>

View File

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

View File

@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAILProtocol" parallel="classes" preserve-order="true" thread-count="1">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"></listener>
</listeners>
<test name="EMAIL">
<method-selectors>
<!-- -DincludeGroups=sanity,comments,people -DexcludeGroups=networks,othergroup -DrunBugs=true -DupdateTestRail=true-->
<method-selector>
<script language="beanshell"><![CDATA[
includedGroups = System.getProperty("includeGroups");
excludedGroups = System.getProperty("excludeGroups");
runBugs = System.getProperty("runBugs");
if((runBugs != null))
{
bugAnnotated = method.getAnnotation(org.alfresco.utility.report.Bug.class);
if (bugAnnotated != null && runBugs.equals("false") )
{
return false;
}
}
if ((includedGroups == null) || (includedGroups.isEmpty())) {
return false;
} else
{
StringTokenizer includedGroupsList = new StringTokenizer(includedGroups, ",");
if ((excludedGroups != null)) {
StringTokenizer excludedGroupsList = new StringTokenizer(excludedGroups, ",");
while (excludedGroupsList.hasMoreTokens()) {
exG = excludedGroupsList.nextToken();
if (groups.containsKey(exG))
{
return false;
}
}
}
while (includedGroupsList.hasMoreTokens()) {
grp = includedGroupsList.nextToken();
if ((groups.containsKey(grp)))
{
return true;
}
}
}
return false;
]]>
</script>
</method-selector>
</method-selectors>
<packages>
<package name="org.alfresco.email.*" />
</packages>
</test>
</suite>

View File

@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAILProtocol" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"></listener>
</listeners>
<test name="Email-Sanity">
<groups>
<run>
<include name="sanity" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.*"></package>
</packages>
</test>
</suite> <!-- Suite -->

View File

@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EMAIL API" preserve-order="true">
<listeners>
<listener class-name="org.alfresco.utility.report.HtmlReportListener"></listener>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener"></listener>
<listener class-name="org.alfresco.utility.testng.OSTestMethodSelector"></listener>
</listeners>
<test name="Sanity">
<groups>
<run>
<include name="sanity" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
<test name="Core">
<groups>
<run>
<include name="core" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
<test name="Full">
<groups>
<run>
<include name="full" />
<exclude name="demo"></exclude>
<exclude name="unit"></exclude>
<!-- networks is related to tenant tests -->
<exclude name="networks"></exclude>
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
<test name="Tenant">
<groups>
<run>
<!-- networks is related to tenant tests -->
<include name="networks" />
</run>
</groups>
<packages>
<package name="org.alfresco.email.imap.*"></package>
<package name="org.alfresco.email.smtp.*"></package>
</packages>
</test>
</suite> <!-- Suite -->

View File

@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Tests for Test Group = sanity" verbose="1">
<listeners>
<listener class-name="org.alfresco.utility.testrail.TestRailExecutorListener" />
<listener class-name="org.alfresco.utility.report.HtmlReportListener" />
</listeners>
<test name="Tas email sanity suite">
<classes>
<class name="org.alfresco.email.imap.ImapMoveMessagesTests">
<methods>
<include name="siteManagerShouldMoveNonEmptyFile" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapMessageFlagsTests">
<methods>
<include name="siteManagerShouldSetFlagsToAContent" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCopyFolderTests">
<methods>
<include name="adminShouldCopyNonEmptyFolder" />
<include name="siteManagerShouldCopyFolder" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapDeleteMessagesTests">
<methods>
<include name="adminShouldDeleteMessage" />
<include name="siteManagerShouldDeleteMessage" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapRenameFolderTests">
<methods>
<include name="adminShouldRenameFolder" />
<include name="siteManagerShouldRenameFolder" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapRenameMessagesTests">
<methods>
<include name="siteManagerShouldVerifyFileContentForRenamedFileViaImap" />
</methods>
</class>
<!-- <class name="org.alfresco.email.imap.ImapSearchMessagesTests">
<methods>
<include name="noResultsReturnedWhenSearchingForNotExistingMessage" />
<include name="searchedMessageIsReturnedWhenSearchingForFullMessageName" />
</methods>
</class> -->
<class name="org.alfresco.email.smtp.SmtpOverwriteDuplicatesTests">
<methods>
<include name="overwriteFileWhenOverwriteDuplicatesIsDisabled" />
<include name="overwriteFileWhenOverwriteDuplicatesIsEnabled" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapDeleteFolderTests">
<methods>
<include name="adminShouldDeleteFolder" />
<include name="siteManagerShouldDeleteNonEmptyFolder" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapReadMessagesTests">
<methods>
<include name="adminShouldGetFoldersCreatedInRepositoryViaImap" />
<include name="siteManagerShouldGetFileAndItsContentsViaImap" />
<include name="siteManagerShouldVerifyFileContent" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapConnectionTests">
<methods>
<include name="correctUserConnectsToIMAPSuccessfully" />
<include name="userDisconnectsFromImapServerSuccessfully" />
<include name="userFailsConnectToIMAPOnDifferentPort" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCopyMessagesTests">
<methods>
<include name="siteManagerShouldCopyNonEmptyFile" />
<include name="siteManagerShouldCopyNonEmptyFiles" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpConnectionTests">
<methods>
<include name="adminShouldConnectToSMTP" />
<include name="adminShouldNotConnectToDisabledServer" />
<!-- <include name="updateSmtpServerPort" /> -->
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCheckFolderTests">
<methods>
<include name="adminShouldGetCurrentWorkingDirectory" />
<include name="siteManagerShouldGetCurrentWorkingDirectory" />
<include name="siteManagerShouldGetDirectoriesListOfRoot" />
<include name="userShouldFindAllIMAPSitesFoldersInAlfrescoIMAPFolder" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpUnknownUserTests">
<methods>
<include name="emailSentSuccessfullyWithAnExistingUser" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpAllowedSendersTests">
<methods>
<include name="sendMailIsSuccessfulForAllowedUser" />
<include name="sendingMailIsSuccessfulForAllUsers" />
<include name="sendingMailIsSuccessfulForUsersBelongingToDomain" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapMoveFolderTests">
<methods>
<include name="adminShouldMoveNonEmptyFolder" />
<include name="siteManagerShouldMoveFolder" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpBlockedSendersTests">
<methods>
<include name="emailSentSuccessfullyWithUserAddedToEmailContributorsGroup" />
<include name="sendMailIsDeniedForAllUsers" />
<include name="sendMailIsDeniedForBlockedUser" />
<include name="sendMailIsDeniedForUsersBelongingToDomain" />
</methods>
</class>
<class name="org.alfresco.email.imap.ImapCreateFolderTests">
<methods>
<include name="adminCanCreateFolderInAlfrescoImapRoot" />
<include name="adminCanCreateFolderInSitesFolder" />
<include name="managerCanCreateFolderInIMAPSite" />
<include name="userCanCreateFolderInAlfrescoImapRootButNotDisplayedInRepo" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpDisableInboundEmailTests">
<methods>
<include name="randomUserCannotConnectWithInboundDisabled" />
</methods>
</class>
<class name="org.alfresco.email.smtp.SmtpFolderAliasTests">
<methods>
<include name="randomUserWithAliasFolderReceivesEmail" />
</methods>
</class>
</classes>
</test>
</suite>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="EmailTests">
<listeners>
<listener class-name="org.alfresco.utility.report.TestCountListener"></listener>
</listeners>
<test name="EmailTests">
<groups>
<run>
<exclude name="demo" />
<exclude name="unit" />
</run>
</groups>
<packages>
<package name="org.alfresco.email.*"></package>
</packages>
</test> <!-- Test -->
</suite> <!-- Suite -->

View File

@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<inputtestdata>
<sites>
<site id="11" name="site1" />
<site id="12" name="test2" />
<site id="13" name="test3" />
</sites>
<folders>
<folder id="11" name="folderA" />
<folder id="111" name="folder1">
<path>/Sites/site1/documentLibrary</path>
<file name="file1" />
</folder>
<folder id="112" name="folder2" />
<folder id="113" name="folder3" />
</folders>
<files>
<file id="11" name="file1" />
<file id="115" name="file2" />
<file id="116" name="file3" />
</files>
<sites>
<site id="221" name="site1" />
<file id="222" name="test2" />
<file id="223" name="test3" />
</sites>
<users>
<user id="331" name="user1" />
<user id="332" name="user2" />
<user id="333" name="1~#a" />
</users>
</inputtestdata>

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.alfresco.tas</groupId>
<artifactId>content-repository-community-integration-test</artifactId>
<name>content-repository-community-integration-test</name>
<version>6.3.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.alfresco</groupId>
<artifactId>content-repository-community-tas-tests-parent</artifactId>
<version>6.3.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<developers>
<developer>
<name>Paul Brodner</name>
<roles>
<role>Test Automation Architect</role>
</roles>
</developer>
</developers>
<properties>
<suiteXmlFile>${project.basedir}/src/test/resources/integration-suite.xml</suiteXmlFile>
<dependency.groovy.version>2.5.5</dependency.groovy.version>
<dependency.javax.mail.version>1.5.1</dependency.javax.mail.version>
</properties>
<dependencies>
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>utility</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>${dependency.javax.mail.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>${dependency.javax.mail.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${dependency.groovy.version}</version>
</dependency>
<!-- FTP -->
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>ftp</artifactId>
<scope>test</scope>
</dependency>
<!-- REST API -->
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>restapi</artifactId>
<scope>test</scope>
</dependency>
<!-- CMIS -->
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>cmis</artifactId>
<scope>test</scope>
</dependency>
<!-- EMAIL: IMAP & SMTP -->
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>email</artifactId>
<scope>test</scope>
</dependency>
<!-- WebDAV -->
<dependency>
<groupId>org.alfresco.tas</groupId>
<artifactId>webdav</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
</suiteXmlFiles>
<argLine>
--illegal-access=warn
</argLine>
</configuration>
</plugin>
<!-- Build only test jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -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);
}
}

View File

@@ -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);
}
}

View File

@@ -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");
}
}

View File

@@ -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()));
}
}

View File

@@ -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<String, String> headers = new HashMap<String, String>();
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");
}
}

View File

@@ -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<String, String> input = new HashMap<String, String>();
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,
"<html><head><title>aegif Mind Share Leader Generating New Paradigms by aegif corporation</title></head><body><p> Test html</p></body></html></body></html>");
String utf8Type = "text/plain;charset=UTF-8";
String iso8859Type = "text/plain;charset=ISO-8859-1";
STEP("2. Upload the files via CMIS.");
cmisAPI.authenticateUser(user).usingSite(site).createFile(utf8File);
cmisAPI.createFile(iso8859File);
String fileCreationWebScript = "alfresco/service/api/node/content/workspace/SpacesStore/";
RestAssured.basePath = "";
STEP("3. Retrieve the nodes via webscripts and verify that the content type is the expected one (GET alfresco/service/api/node/content/workspace/SpacesStore/).");
restAPI.configureRequestSpec().setBasePath(RestAssured.basePath);
RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, fileCreationWebScript + utf8File.getNodeRefWithoutVersion());
RestResponse response = restAPI.authenticateUser(user).process(request);
Assert.assertEquals(response.getResponse().getStatusCode(), HttpStatus.OK.value());
Assert.assertEquals(response.getResponse().getContentType(), utf8Type);
request = RestRequest.simpleRequest(HttpMethod.GET, fileCreationWebScript + iso8859File.getNodeRefWithoutVersion());
response = restAPI.process(request);
Assert.assertEquals(response.getResponse().getStatusCode(), HttpStatus.OK.value());
Assert.assertEquals(response.getResponse().getContentType(), iso8859Type);
// Commented the use of v1 RestAPI GET (nodes/{nodeId}), because it works on alfresco 5.2.N or above.
// STEP("3. Retrieve the nodes and verify that the content type is the expected one (GET nodes/{nodeId}).");
// restAPI.authenticateUser(user).withCoreAPI().usingNode(utf8File).getNodeContent().assertThat().contentType(utf8Type);
// restAPI.authenticateUser(user).withCoreAPI().usingNode(iso8859File).getNodeContent().assertThat().contentType(iso8859Type);
}
}

View File

@@ -0,0 +1,82 @@
package org.alfresco.tas.integration;
import static org.alfresco.utility.report.log.Step.STEP;
import io.restassured.RestAssured;
import io.restassured.http.Cookie;
import io.restassured.response.Response;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.List;
import org.alfresco.rest.core.JsonBodyGenerator;
import org.alfresco.rest.core.RestRequest;
import org.alfresco.rest.model.RestPersonModel;
import org.alfresco.utility.Utility;
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.codec.binary.Base64;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.testng.Assert;
import org.testng.annotations.Test;
public class IntegrationWithWebScriptsTests extends IntegrationTest
{
@Test(groups = { TestGroup.INTEGRATION, TestGroup.REST_API, TestGroup.FULL })
@TestRail(section = { TestGroup.INTEGRATION,
TestGroup.REST_API }, executionType = ExecutionType.REGRESSION, description = "Verify when importing multiple users via CSV, if the password is not set in the CSV file, user will be disable")
public void verifyCSVUserImportDisableUserAndGivesRandomPasswordIfItIsMissing() throws Exception
{
STEP("1.Upload the CSV File that contains the users.");
restAPI.authenticateUser(dataUser.getAdminUser()).configureRequestSpec().addMultiPart("filedata",
Utility.getResourceTestDataFile("userCSV.csv"));
String fileCreationWebScript = "alfresco/s/api/people/upload";
RestAssured.basePath = "";
restAPI.configureRequestSpec().setBasePath(RestAssured.basePath);
RestRequest request = RestRequest.simpleRequest(HttpMethod.POST, fileCreationWebScript);
restAPI.authenticateUser(dataUser.getAdminUser()).process(request);
restAPI.assertStatusCodeIs(HttpStatus.OK);
STEP("2.Verify that user1np is disabled and user2 is enabled");
UserModel disabledUserPerson = new UserModel("MNT-171990-user-with-no-password", "user1");
UserModel enabledUserPerson = new UserModel("MNT-171990-user-with-password", "user2");
RestPersonModel personModel = restAPI.authenticateUser(dataUser.getAdminUser()).withCoreAPI()
.usingUser(new UserModel(disabledUserPerson.getUsername(), disabledUserPerson.getPassword())).getPerson();
restAPI.assertStatusCodeIs(HttpStatus.OK);
personModel.assertThat().field("enabled").is("false");
personModel = restAPI.authenticateUser(dataUser.getAdminUser()).withCoreAPI()
.usingUser(new UserModel(enabledUserPerson.getUsername(), enabledUserPerson.getPassword())).getPerson();
restAPI.assertStatusCodeIs(HttpStatus.OK);
personModel.assertThat().field("enabled").is("true");
STEP("3.Activate the disabled user.");
HashMap<String, String> input = new HashMap<String, String>();
input.put("enabled", "true");
String putBody = JsonBodyGenerator.keyValueJson(input);
restAPI.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(disabledUserPerson).updatePerson(putBody);
restAPI.assertStatusCodeIs(HttpStatus.OK);
STEP("4.Verify that the disabled user has a randomly generated password not the same as firstname(DOCS-2755)");
restAPI.authenticateUser(disabledUserPerson).withCoreAPI()
.usingUser(new UserModel(enabledUserPerson.getUsername(), enabledUserPerson.getPassword())).getPerson();
restAPI.assertStatusCodeIs(HttpStatus.UNAUTHORIZED);
STEP("5.Change the user password and try an Rest API call.");
input = new HashMap<String, String>();
input.put("password", "newPassword1");
putBody = JsonBodyGenerator.keyValueJson(input);
restAPI.authenticateUser(dataUser.getAdminUser()).withCoreAPI().usingUser(disabledUserPerson).updatePerson(putBody);
restAPI.assertStatusCodeIs(HttpStatus.OK);
disabledUserPerson = new UserModel(disabledUserPerson.getUsername(), "newPassword1");
restAPI.authenticateUser(disabledUserPerson).withCoreAPI()
.usingUser(new UserModel(enabledUserPerson.getUsername(), enabledUserPerson.getPassword())).getPerson();
restAPI.assertStatusCodeIs(HttpStatus.OK);
dataUser.usingAdmin().deleteUser(disabledUserPerson);
dataUser.usingAdmin().deleteUser(enabledUserPerson);
}
}

Some files were not shown because too many files have changed in this diff Show More