From bce77b45160ad2195cca137898ac351ee4043759 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Thu, 30 Jul 2020 08:42:48 +0100 Subject: [PATCH] WIP: REPO-5266 Remove duplicate TAS code (#2) --- .travis.yml | 46 +- core/pom.xml | 354 +- data-model/pom.xml | 674 ++-- packaging/tests/scripts/start-compose.sh | 17 + packaging/tests/tas-cmis/pom.xml | 128 +- .../java/org/alfresco/email/EmailTest.java | 202 +- .../email/imap/ImapReadMessagesTests.java | 351 +- .../tas/integration/IntegrationCoreTests.java | 2988 ++++++++--------- .../org/alfresco/rest/nodes/NodesTests.java | 185 +- .../rest/people/GetPeopleFullTests.java | 176 +- .../sites/members/GetSiteMemberTests.java | 790 ++--- .../sites/members/GetSiteMembersTests.java | 708 ++-- packaging/war/pom.xml | 564 ++-- pom.xml | 54 +- 14 files changed, 3681 insertions(+), 3556 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8db6481d2c..0bf76aca3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ services: cache: directories: - $HOME/.m2 -# the cache can grow constantly + before_cache: - rm -rf $HOME/.m2/repository/org/alfresco/alfresco-community-repo - rm -rf $HOME/.m2/repository/org/alfresco/alfresco-core @@ -25,6 +25,12 @@ branches: only: - master - /release\/.*/ + - feature/REPO-5266_dup_tas_code + +env: + global: + - TAS_SCRIPTS=../alfresco-community-repo/packaging/tests/scripts + - TAS_COMMUNITY=../alfresco-community-repo/packaging/tests/environment stages: - name: test @@ -176,60 +182,58 @@ jobs: - name: "REST API TAS tests part1" jdk: openjdk11 install: - - docker images - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal+transforms.yml - - docker images - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal+transforms.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - travis_wait 60 mvn install -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part1 -Denvironment=default -DrunBugs=false - name: "REST API TAS tests part2" jdk: openjdk11 install: - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal+transforms.yml - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal+transforms.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - travis_wait 60 mvn install -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part2 -Denvironment=default -DrunBugs=false - name: "REST API TAS tests part3" jdk: openjdk11 install: - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal+transforms.yml - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal+transforms.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - travis_wait 60 mvn install -f packaging/tests/tas-restapi/pom.xml -Pall-tas-tests,run-restapi-part3 -Denvironment=default -DrunBugs=false - name: "CMIS TAS tests" jdk: openjdk11 install: - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal+transforms.yml - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal+transforms.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - - travis_wait 40 mvn install -q -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - travis_wait 40 mvn install -f packaging/tests/tas-cmis/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - name: "Email TAS tests" jdk: openjdk11 install: - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal.yml - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - - travis_wait 30 mvn install -q -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - travis_wait 30 mvn install -f packaging/tests/tas-email/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - name: "WebDAV TAS tests" jdk: openjdk11 install: - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal.yml - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - - travis_wait 30 mvn install -q -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - travis_wait 30 mvn install -f packaging/tests/tas-webdav/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false - name: "Integration TAS tests" jdk: openjdk11 install: - - ./packaging/tests/scripts/start-compose.sh ./packaging/tests/environment/docker-compose-minimal.yml - - ./packaging/tests/scripts/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" + - ${TAS_SCRIPTS}/start-compose.sh ${TAS_COMMUNITY}/docker-compose-minimal.yml + - ${TAS_SCRIPTS}/wait-for-alfresco-start.sh "http://localhost:8082/alfresco" script: - - travis_wait 30 mvn install -q -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false + - travis_wait 30 mvn install -f packaging/tests/tas-integration/pom.xml -Pall-tas-tests -Denvironment=default -DrunBugs=false # Comment out for now to avoid pushing 8.300 to nuxus until we are ready # - stage: release diff --git a/core/pom.xml b/core/pom.xml index cc9810670e..02c0ccdbd6 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -1,177 +1,177 @@ - - 4.0.0 - alfresco-core - Alfresco Core - Alfresco core libraries and utils - - - org.alfresco - alfresco-community-repo - 8.300-SNAPSHOT - - - - scm:git:https://github.com/Alfresco/alfresco-core.git - scm:git:https://github.com/Alfresco/alfresco-core.git - https://github.com/Alfresco/alfresco-core - HEAD - - - - - alfresco-public - https://artifacts.alfresco.com/nexus/content/repositories/releases - - - - - - commons-codec - commons-codec - - - commons-httpclient - commons-httpclient - - - commons-logging - commons-logging - - - commons-io - commons-io - - - org.apache.commons - commons-math3 - 3.6.1 - - - org.safehaus.jug - jug - 2.0.0 - asl - - - log4j - log4j - 1.2.17 - - - org.json - json - - - org.springframework - spring-orm - - - - - org.springframework - spring-jcl - - - - - org.springframework - spring-context - - - org.quartz-scheduler - quartz - - - - - com.mchange - * - - - - - org.alfresco.surf - spring-surf-core-configservice - - - jakarta.xml.bind - jakarta.xml.bind-api - - - com.sun.xml.bind - jaxb-core - 2.3.0.1 - - - org.codehaus.guessencoding - guessencoding - 1.4 - - - jakarta.transaction - jakarta.transaction-api - - - joda-time - joda-time - - - - - javax.servlet - javax.servlet-api - provided - - - - - org.slf4j - slf4j-log4j12 - test - - - junit - junit - test - - - org.mockito - mockito-core - test - - - commons-dbcp - commons-dbcp - test - - - - - - - - maven-release-plugin - - true - @{project.version} - - - - - - - - maven-jar-plugin - 3.2.0 - - - - test-jar - - - - - - - - + + 4.0.0 + alfresco-core + Alfresco Core + Alfresco core libraries and utils + + + org.alfresco + alfresco-community-repo + 8.300-SNAPSHOT + + + + scm:git:https://github.com/Alfresco/alfresco-core.git + scm:git:https://github.com/Alfresco/alfresco-core.git + https://github.com/Alfresco/alfresco-core + HEAD + + + + + alfresco-public + https://artifacts.alfresco.com/nexus/content/repositories/releases + + + + + + commons-codec + commons-codec + + + commons-httpclient + commons-httpclient + + + commons-logging + commons-logging + + + commons-io + commons-io + + + org.apache.commons + commons-math3 + 3.6.1 + + + org.safehaus.jug + jug + 2.0.0 + asl + + + log4j + log4j + 1.2.17 + + + org.json + json + + + org.springframework + spring-orm + + + + + org.springframework + spring-jcl + + + + + org.springframework + spring-context + + + org.quartz-scheduler + quartz + + + + + com.mchange + * + + + + + org.alfresco.surf + spring-surf-core-configservice + + + jakarta.xml.bind + jakarta.xml.bind-api + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + + + org.codehaus.guessencoding + guessencoding + 1.4 + + + jakarta.transaction + jakarta.transaction-api + + + joda-time + joda-time + + + + + javax.servlet + javax.servlet-api + provided + + + + + org.slf4j + slf4j-log4j12 + test + + + junit + junit + test + + + org.mockito + mockito-core + test + + + commons-dbcp + commons-dbcp + test + + + + + + + + maven-release-plugin + + true + @{project.version} + + + + + + + + maven-jar-plugin + ${dependency.maven-jar-plugin.version} + + + + test-jar + + + + + + + + diff --git a/data-model/pom.xml b/data-model/pom.xml index 4e85a77870..abcab48ca1 100644 --- a/data-model/pom.xml +++ b/data-model/pom.xml @@ -1,337 +1,337 @@ - - 4.0.0 - alfresco-data-model - Alfresco Data Model - Alfresco Data Model classes - - - org.alfresco - alfresco-community-repo - 8.300-SNAPSHOT - - - - scm:git:https://github.com/Alfresco/alfresco-data-model.git - scm:git:https://github.com/Alfresco/alfresco-data-model.git - https://github.com/Alfresco/alfresco-data-model - HEAD - - - - - alfresco-public - https://artifacts.alfresco.com/nexus/content/repositories/releases - - - - - 1.24.1 - - - source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java, - source/java/org/alfresco/repo/search/impl/parsers/FTSParser.java, - source/java/org/alfresco/repo/search/impl/parsers/FTSLexer.java - - - - - - - org.jibx - maven-jibx-plugin - - true - ${project.build.sourceDirectory}/org/alfresco/repo/dictionary - - m2binding.xml - - - - - bind-sources - - bind - - - - - - - - maven-antrun-plugin - - - duplicate-english-messages - generate-resources - - run - - - - - - - - - - - - - - maven-jar-plugin - 3.2.0 - - - - test-jar - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.jibx - - maven-jibx-plugin - - - [1.2.5,) - - - bind - - - - - true - true - - - - - - - - - maven-release-plugin - - true - @{project.version} - - - - - - - - - org.alfresco - alfresco-core - - - - javax.servlet - javax.servlet-api - provided - - - - org.jibx - jibx-run - 1.3.3 - - - com.fasterxml.jackson.core - jackson-annotations - 2.11.1 - - - org.antlr - antlr - ${dependency.antlr.version} - - - - com.fasterxml.woodstox - woodstox-core - 5.0.3 - - - - jakarta.jws - jakarta.jws-api - 1.1.1 - - - - jakarta.transaction - jakarta.transaction-api - - - - jakarta.annotation - jakarta.annotation-api - 1.3.5 - - - - com.sun.activation - jakarta.activation - 1.2.2 - - - - org.apache.chemistry.opencmis - chemistry-opencmis-commons-impl - ${dependency.opencmis.version} - - - com.sun.xml.messaging.saaj - saaj-impl - - - - org.codehaus.woodstox - woodstox-core-asl - - - - - org.apache.chemistry.opencmis - chemistry-opencmis-server-bindings - ${dependency.opencmis.version} - - - commons-lang - commons-lang3 - - - - org.apache.geronimo.specs - geronimo-ws-metadata_2.0_spec - - - - org.apache.geronimo.specs - geronimo-jta_1.1_spec - - - - javax.annotation - javax.annotation-api - - - - com.sun.activation - javax.activation - - - - - - org.acegisecurity - acegi-security - 0.8.2_patched - - - org.alfresco - alfresco-xmlfactory - 1.3 - - - xerces - xercesImpl - - - - org.apache.tika - tika-core - ${dependency.tika.version} - - - org.apache.tika - tika-parsers - ${dependency.tika.version} - - - com.tdunning - json - - - org.bouncycastle - bcprov-jdk15on - - - asm - asm - - - - org.glassfish.jaxb - txw2 - - - com.sun.istack - istack-commons-runtime - - - - org.apache.geronimo.specs - geronimo-ws-metadata_2.0_spec - - - - org.apache.geronimo.specs - geronimo-jta_1.1_spec - - - - javax.annotation - javax.annotation-api - - - - com.sun.activation - javax.activation - - - - - - - junit - junit - test - - - org.antlr - gunit - test - - - org.mockito - mockito-core - test - - - - + + 4.0.0 + alfresco-data-model + Alfresco Data Model + Alfresco Data Model classes + + + org.alfresco + alfresco-community-repo + 8.300-SNAPSHOT + + + + scm:git:https://github.com/Alfresco/alfresco-data-model.git + scm:git:https://github.com/Alfresco/alfresco-data-model.git + https://github.com/Alfresco/alfresco-data-model + HEAD + + + + + alfresco-public + https://artifacts.alfresco.com/nexus/content/repositories/releases + + + + + 1.24.1 + + + source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java, + source/java/org/alfresco/repo/search/impl/parsers/FTSParser.java, + source/java/org/alfresco/repo/search/impl/parsers/FTSLexer.java + + + + + + + org.jibx + maven-jibx-plugin + + true + ${project.build.sourceDirectory}/org/alfresco/repo/dictionary + + m2binding.xml + + + + + bind-sources + + bind + + + + + + + + maven-antrun-plugin + + + duplicate-english-messages + generate-resources + + run + + + + + + + + + + + + + + maven-jar-plugin + ${dependency.maven-jar-plugin.version} + + + + test-jar + + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.jibx + + maven-jibx-plugin + + + [1.2.5,) + + + bind + + + + + true + true + + + + + + + + + maven-release-plugin + + true + @{project.version} + + + + + + + + + org.alfresco + alfresco-core + + + + javax.servlet + javax.servlet-api + provided + + + + org.jibx + jibx-run + 1.3.3 + + + com.fasterxml.jackson.core + jackson-annotations + 2.11.1 + + + org.antlr + antlr + ${dependency.antlr.version} + + + + com.fasterxml.woodstox + woodstox-core + 5.0.3 + + + + jakarta.jws + jakarta.jws-api + 1.1.1 + + + + jakarta.transaction + jakarta.transaction-api + + + + jakarta.annotation + jakarta.annotation-api + 1.3.5 + + + + com.sun.activation + jakarta.activation + 1.2.2 + + + + org.apache.chemistry.opencmis + chemistry-opencmis-commons-impl + ${dependency.opencmis.version} + + + com.sun.xml.messaging.saaj + saaj-impl + + + + org.codehaus.woodstox + woodstox-core-asl + + + + + org.apache.chemistry.opencmis + chemistry-opencmis-server-bindings + ${dependency.opencmis.version} + + + commons-lang + commons-lang3 + + + + org.apache.geronimo.specs + geronimo-ws-metadata_2.0_spec + + + + org.apache.geronimo.specs + geronimo-jta_1.1_spec + + + + javax.annotation + javax.annotation-api + + + + com.sun.activation + javax.activation + + + + + + org.acegisecurity + acegi-security + 0.8.2_patched + + + org.alfresco + alfresco-xmlfactory + 1.3 + + + xerces + xercesImpl + + + + org.apache.tika + tika-core + ${dependency.tika.version} + + + org.apache.tika + tika-parsers + ${dependency.tika.version} + + + com.tdunning + json + + + org.bouncycastle + bcprov-jdk15on + + + asm + asm + + + + org.glassfish.jaxb + txw2 + + + com.sun.istack + istack-commons-runtime + + + + org.apache.geronimo.specs + geronimo-ws-metadata_2.0_spec + + + + org.apache.geronimo.specs + geronimo-jta_1.1_spec + + + + javax.annotation + javax.annotation-api + + + + com.sun.activation + javax.activation + + + + + + + junit + junit + test + + + org.antlr + gunit + test + + + org.mockito + mockito-core + test + + + + diff --git a/packaging/tests/scripts/start-compose.sh b/packaging/tests/scripts/start-compose.sh index ace065bb0c..96c5cacf20 100755 --- a/packaging/tests/scripts/start-compose.sh +++ b/packaging/tests/scripts/start-compose.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash export DOCKER_COMPOSE_PATH=$1 +export CLEAN_UP="$2" if [ -z "$DOCKER_COMPOSE_PATH" ] then @@ -8,6 +9,22 @@ then exit 1 fi +# Cleans up any generated images. These are created if the docker-compose file has "build:" clauses. They are not +# recreated if an image with the same name already exist. Also cleans up existing containers. Generally only needed on +# dev systems, however... +# The second parameter can be used to avoid doing a clean up if we are doing a restart test. +if [ "$CLEAN_UP" != "no-clean-up" ] +then + docker-compose --file "${DOCKER_COMPOSE_PATH}" kill + docker-compose --file "${DOCKER_COMPOSE_PATH}" rm -f + + export GENERATED_IMAGES=$(docker images | grep '^environment_' | awk '{ print $3 }') + if [ -n "$GENERATED_IMAGES" ] + then + docker image rm -f $GENERATED_IMAGES + fi +fi + echo "Starting ACS stack in ${DOCKER_COMPOSE_PATH}" # .env files are picked up from project directory correctly on docker-compose 1.23.0+ diff --git a/packaging/tests/tas-cmis/pom.xml b/packaging/tests/tas-cmis/pom.xml index 7fa8926055..969bced1df 100644 --- a/packaging/tests/tas-cmis/pom.xml +++ b/packaging/tests/tas-cmis/pom.xml @@ -1,64 +1,64 @@ - - - 4.0.0 - org.alfresco.tas - alfresco-community-repo-cmis-test - cmis test - jar - - - org.alfresco - alfresco-community-repo-tests - 8.300-SNAPSHOT - - - - - Paul Brodner - - Test Automation Architect - - - - - - ${project.basedir}/src/test/resources/cmis-suite.xml - - - - - org.alfresco.tas - cmis - test - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - ${suiteXmlFile} - - - --illegal-access=warn - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - test-jar - - - - - - - + + + 4.0.0 + org.alfresco.tas + alfresco-community-repo-cmis-test + cmis test + jar + + + org.alfresco + alfresco-community-repo-tests + 8.300-SNAPSHOT + + + + + Paul Brodner + + Test Automation Architect + + + + + + ${project.basedir}/src/test/resources/cmis-suite.xml + + + + + org.alfresco.tas + cmis + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${suiteXmlFile} + + + --illegal-access=warn + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + + diff --git a/packaging/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java b/packaging/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java index 2a1a1b4a58..d29f7cc95f 100644 --- a/packaging/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java +++ b/packaging/tests/tas-email/src/test/java/org/alfresco/email/EmailTest.java @@ -1,100 +1,102 @@ -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())); - } -} +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 + protected EmailProperties emailProperties; + + @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()); + } + + if (emailProperties.getUseJolokiaAgent()) + { + imapProtocol.assertThat().protocolIsEnabled(); + smtpProtocol.assertThat().protocolIsEnabled(); + ServerConfiguration.save(smtpProtocol.withJMX(), smtpProtocol.emailProperties); + } + else + { + LOG.warn("*** Jolokia is not used! To use jolokia, please add next system property when running the tests: jmx.useJolokiaAgent=true ***"); + } + } + + @BeforeMethod(alwaysRun=true) + public void showStartTestInfo(Method method) + { + LOG.info(String.format("*** STARTING Test: [%s] ***",method.getName())); + } + + @AfterMethod(alwaysRun=true) + public void showEndTestInfo(Method method) + { + LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); + } +} diff --git a/packaging/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java b/packaging/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java index 9419f16216..74e1fc451f 100644 --- a/packaging/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java +++ b/packaging/tests/tas-email/src/test/java/org/alfresco/email/imap/ImapReadMessagesTests.java @@ -1,180 +1,171 @@ -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(); - } -} +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 collaborator can see files created by self") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }) + public void collaboratorCanViewFileCreatedBySelf() throws Exception + { + UserModel collaboratorUser = dataUser.createRandomTestUser(); + dataUser.addUserToSite(collaboratorUser, testSite, UserRole.SiteCollaborator); + testFile = dataContent.usingUser(collaboratorUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN)); + imapProtocol.authenticateUser(collaboratorUser).usingSite(testSite).assertThat().containsMessages(testFile); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that contributor can see files created by self") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }) + public void contributorCanViewFileCreatedBySelf() throws Exception + { + UserModel contributorUser = dataUser.createRandomTestUser(); + dataUser.addUserToSite(contributorUser, testSite, UserRole.SiteContributor); + testFile = dataContent.usingUser(contributorUser).usingSite(testSite).createContent(FileModel.getRandomFileModel(FileType.TEXT_PLAIN)); + imapProtocol.authenticateUser(contributorUser).usingSite(testSite).assertThat().containsMessages(testFile); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify file created with spaces in the name is displayed in IMAP client") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.CORE }) + public void fileWithSpacesInNameIsDisplayedInImap() throws Exception + { + testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("name with spaces.txt", FileType.TEXT_PLAIN)); + imapProtocol.authenticateUser(testUser).usingSite(testSite).assertThat().containsMessages(testFile); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that a file created with name which contains special characters is visible in IMAP") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }) + public void userCanViewFileWithSpecialCharactersInNameViaIMAP() throws Exception + { + testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("(a)[b]!#%^.txt", FileType.TEXT_PLAIN)); + imapProtocol.authenticateUser(testUser) + .usingSite(testSite).assertThat().containsMessages(testFile) + .usingResource(testFile).assertThat().existsInRepo(); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that a file created with name which contains symbols is visible in IMAP") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }) + public void userCanViewFileWithSymbolsInNameViaIMAP() throws Exception + { + testFile = dataContent.usingUser(testUser).usingSite(testSite).createContent(new FileModel("a£¥€$♊♎♏♐♑♒♓Ω.txt", FileType.TEXT_PLAIN)); + imapProtocol.authenticateUser(testUser) + .usingSite(testSite).assertThat().containsMessages(testFile) + .usingResource(testFile).assertThat().existsInRepo(); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that site manager can see links via IMAP") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }) + public void siteManagerCanViewLinks() throws Exception + { + dataLink.usingUser(testUser).usingSite(testSite).createRandomLink(); + imapProtocol.authenticateUser(testUser).usingSiteLinksContainer(testSite).assertThat().countMessagesIs(1); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that site manager can see calendar events via IMAP") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }) + public void siteManagerCanViewCalendarEvents() throws Exception + { + dataCalendarEvent.usingUser(testUser).usingSite(testSite).createRandomCalendarEvent(); + imapProtocol.authenticateUser(testUser).usingSiteCalendarContainer(testSite).assertThat().countMessagesIs(1); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that site manager cannot read file via IMAP if it is already deleted from repository") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = MessagingException.class, + expectedExceptionsMessageRegExp = "No message with subject .* has been found") + public void siteManagerCannotReadFileInImapIfItWasDeletedFromRepository() throws Exception + { + testFile = dataContent.usingUser(testUser).usingSite(testSite) + .createContent(new FileModel(RandomData.getRandomName("File"), FileType.TEXT_PLAIN)); + dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFile).deleteContent(); + imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().fileContentIsDisplayed(); + } + + @TestRail(section = { TestGroup.PROTOCOLS, TestGroup.IMAP }, executionType = ExecutionType.REGRESSION, + description = "Verify that site manager cannot read file via IMAP client if it is locked by an user in repository") + @Test(groups = { TestGroup.PROTOCOLS, TestGroup.IMAP, TestGroup.FULL }, expectedExceptions = IOException.class, + expectedExceptionsMessageRegExp = "No content") + public void siteManagerCannotReadFileInImapIfItsLocked() throws Exception + { + String content = RandomData.getRandomAlphanumeric(); + testFile = dataContent.usingUser(testUser).usingSite(testSite) + .createContent(new FileModel(RandomData.getRandomName("File"), FileType.TEXT_PLAIN, content)); + dataContent.usingUser(testUser).usingSite(testSite).usingResource(testFile).checkOutDocument(); + imapProtocol.authenticateUser(testUser).usingSite(testSite).usingResource(testFile).assertThat().fileContentIsDisplayed(); + } +} diff --git a/packaging/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java b/packaging/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java index 7f211292c1..bf46fae5b5 100644 --- a/packaging/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java +++ b/packaging/tests/tas-integration/src/test/java/org/alfresco/tas/integration/IntegrationCoreTests.java @@ -1,1494 +1,1494 @@ -package org.alfresco.tas.integration; - -import static org.alfresco.utility.report.log.Step.STEP; - -import javax.mail.FolderNotFoundException; - -import org.alfresco.rest.model.RestCommentModel; -import org.alfresco.rest.model.RestDeploymentModel; -import org.alfresco.rest.model.RestDeploymentModelsCollection; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestPersonFavoritesModel; -import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; -import org.alfresco.rest.model.RestRatingModel; -import org.alfresco.utility.Utility; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.RandomData; -import org.alfresco.utility.model.*; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; -import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException; -import org.apache.commons.lang3.RandomStringUtils; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -import junit.framework.Assert; - -/** - * Created by Claudia Agache on 12/13/2016. - */ -public class IntegrationCoreTests extends IntegrationTest -{ - UserModel testUser1, testUser2; - SiteModel testSitePublic, testSiteModerated, testSitePrivate, secondPublicSite; - FolderModel testFolder1, testFolder2, parentFolder1; - private String renamePrefix = "edited-"; - FileModel testFile1, testFile2, childDoc1, childDoc2, childDoc3, childDoc4, childDoc5; - RestRatingModel returnedRatingModel; - RestPersonFavoritesModel restPersonFavoritesModel; - private String newContent = "new TAS content"; - - /** - * Scenario 22 - * 1. Using CMIS create 2 test users: u1 and u2 - * 2. U1 creates a public test site and U2 a public test site using CMIS - * 3. U1 creates a folder with a file in his public site's document library using WebDav - * 4. U1 tries to move his folder to U2 public site using IMAP - * 5. Verify folder with file is not moved. U1 is not authorized to access the public site - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user is not able to move a folder with a file to a public site if he is not a member of that site.") - public void moveFolderWithFileToPublicSiteByUninvitedUser() throws Exception - { - STEP("1. Using CMIS create 2 test users: u1 and u2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. U1 creates a public test site and U2 a public test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - secondPublicSite = dataSite.usingUser(testUser2).createIMAPSite(); - - STEP("3. U1 creates a folder with a file in public site's document library using WebDav"); - testFolder1 = FolderModel.getRandomFolderModel(); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content"); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) - .createFolder(testFolder1).assertThat().existsInWebdav() - .usingResource(testFolder1).createFile(testFile1).assertThat().existsInRepo(); - - STEP("4. U1 tries to move his folder to U2 public site using IMAP. 5. Verify folder with file is not moved. U1 is not authorized to access the U2 public site"); - FolderModel destination = new FolderModel(Utility.buildPath("Sites", secondPublicSite.getId(), "documentLibrary")); - destination.setProtocolLocation(imapProtocol.authenticateUser(testUser2).usingSite(secondPublicSite).getLastResourceWithoutPrefix()); - imapProtocol.authenticateUser(testUser1) - .usingResource(testFolder1).moveTo(destination) - .assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 23 - * 1. Using CMIS create 1 test user: u1 - * 2. U1 creates a public test site - * 3. U1 creates a folder (parentFolder) inside public site's document library using WebDav - * 4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP - * 5. Inside parentFolder create 1 subfolder using IMAP - * 6. Delete parentFolder using CMIS - * 7. Verify folder is deleted along with all its children - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to delete parent folder along with all its children using CMIS.") - public void deleteFolderWithChildrenUsingCMIS() throws Exception - { - STEP("1. Using CMIS create 1 test user: u1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. U1 creates a public test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); - - STEP("3. U1 creates a folder (parentFolder) inside public site's document library using WebDav"); - FolderModel parentFolder = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1) - .usingSite(testSitePublic).createFolder(parentFolder) - .assertThat().existsInWebdav() - .and().assertThat().existsInRepo(); - - STEP("4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP"); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD); - FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML); - FileModel testFile4 = FileModel.getRandomFileModel(FileType.EXE); - cmisAPI.authenticateUser(testUser1).usingResource(parentFolder) - .createFile(testFile1).assertThat().existsInRepo(); - webDavProtocol.usingResource(parentFolder).createFile(testFile2) - .assertThat().existsInWebdav().and() - .assertThat().existsInRepo(); - cmisAPI.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile3) - .assertThat().existsInRepo(); - ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile4) - .assertThat().existsInFtp().and() - .assertThat().existsInRepo(); - - STEP("5. Inside parentFolder create 1 subfolder using IMAP"); - testFolder1 = FolderModel.getRandomFolderModel(); - imapProtocol.authenticateUser(testUser1) - .usingResource(parentFolder).createFolder(testFolder1) - .assertThat().existsInImap().and() - .assertThat().existsInRepo(); - - STEP("6. Delete parentFolder using CMIS 7. Verify folder is deleted along with all its children"); - cmisAPI.usingResource(parentFolder).deleteFolderTree().and().assertThat().doesNotExistInRepo() - .usingResource(testFolder1).assertThat().doesNotExistInRepo() - .usingResource(testFile1).assertThat().doesNotExistInRepo() - .usingResource(testFile2).assertThat().doesNotExistInRepo() - .usingResource(testFile3).assertThat().doesNotExistInRepo() - .usingResource(testFile4).assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 24 - * 1. Using CMIS create 1 test user: u1 - * 2. U1 creates a public test site - * 3. U1 creates a folder (parentFolder) inside public site's document library using IMAP - * 4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP - * 5. Inside parentFolder create 1 subfolder using WebDAV - * 6. Delete parentFolder using WebDAV - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to delete parent folder along with all its children using WebDAV.") - public void deleteFolderWithChildrenUsingWebDAV() throws Exception - { - STEP("1. Using CMIS create 1 test user: u1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. U1 creates a public test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); - - STEP("3. U1 creates a folder (parentFolder) inside public site's document library using IMAP"); - FolderModel parentFolder = FolderModel.getRandomFolderModel(); - imapProtocol.authenticateUser(testUser1) - .usingSite(testSitePublic).createFolder(parentFolder) - .assertThat().existsInImap().and() - .assertThat().existsInRepo(); - - STEP("4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP"); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD); - FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML); - FileModel testFile4 = FileModel.getRandomFileModel(FileType.EXE); - cmisAPI.authenticateUser(testUser1).usingResource(parentFolder) - .createFile(testFile1).assertThat().existsInRepo(); - webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile2) - .assertThat().existsInWebdav().and() - .assertThat().existsInRepo(); - ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile4) - .assertThat().existsInFtp().and() - .assertThat().existsInRepo(); - - STEP("5. Inside parentFolder create 1 subfolder using WebDAV"); - testFolder1 = FolderModel.getRandomFolderModel(); - webDavProtocol.usingResource(parentFolder).createFolder(testFolder1) - .assertThat().existsInWebdav() - .and().assertThat().existsInRepo(); - - STEP("6. Delete parentFolder using WebDAV 7. Verify folder is deleted along with all its children"); - webDavProtocol.usingResource(parentFolder).delete().and().assertThat().doesNotExistInRepo() - .usingResource(testFolder1).assertThat().doesNotExistInRepo() - .usingResource(testFile1).assertThat().doesNotExistInRepo() - .usingResource(testFile2).assertThat().doesNotExistInRepo() - .usingResource(testFile3).assertThat().doesNotExistInRepo() - .usingResource(testFile4).assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 25 - * 1. Using CMIS create 2 test users: u1 and u2 - * 2. U1 creates a public test site and adds u2 as manager to his site using CMIS - * 3. U1 creates a folder (parentFolder) inside public site's document library using CMIS - * 4. U1 creates a subfolder1 and a file1 inside parentFolder using FTP - * 5. U1 creates a subfolder2 and a file2 inside subfolder1 using CMIS - * 6. U2 creates a subfolder3 and a file3 using WebDAV - * 7. U2 deletes parentFolder using FTP - * 8. Verify folder is deleted along with all its children - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user is able to delete parent folder along with all its children using FTP.") - public void deleteFolderWithChildrenUsingFTP() throws Exception - { - STEP("1. Using CMIS create 2 test users: u1 and u2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. U1 creates a public test site using CMIS and adds u2 as manager to his site using REST"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteManager); - testUser2.setUserRole(UserRole.SiteManager); - - STEP("3. U1 creates a folder (parentFolder) inside public site's document library using CMIS"); - FolderModel parentFolder = FolderModel.getRandomFolderModel(); - cmisAPI.authenticateUser(testUser1) - .usingSite(testSitePublic).createFolder(parentFolder) - .assertThat().existsInRepo(); - - STEP("4. U1 creates a subfolder1 and a file1 inside parentFolder using FTP"); - FolderModel subFolder1 = FolderModel.getRandomFolderModel(); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - ftpProtocol.authenticateUser(testUser1) - .usingResource(parentFolder).createFolder(subFolder1) - .assertThat().existsInRepo() - .assertThat().existsInFtp() - .usingResource(parentFolder).createFile(testFile1) - .assertThat().existsInRepo() - .assertThat().existsInFtp(); - - STEP("5. U1 creates a subfolder2 and a file2 inside subfolder1 using CMIS"); - FolderModel subFolder2 = FolderModel.getRandomFolderModel(); - FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD); - - cmisAPI.authenticateUser(testUser1).usingResource(subFolder1) - .createFolder(subFolder2) - .assertThat().existsInRepo() - .createFile(testFile2) - .assertThat().existsInRepo(); - - STEP("6. U2 creates a subfolder3 and a file3 using WebDAV"); - FolderModel subFolder3 = FolderModel.getRandomFolderModel(); - FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML); - - webDavProtocol.authenticateUser(testUser2).usingResource(subFolder2) - .createFolder(subFolder3) - .assertThat().existsInWebdav() - .assertThat().existsInRepo() - .createFile(testFile3) - .assertThat().existsInWebdav() - .assertThat().existsInRepo(); - - STEP("7. U2 deletes parentFolder using FTP"); - ftpProtocol.authenticateUser(testUser2) - .usingResource(parentFolder).assertThat().existsInFtp() - .then().delete() - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp() - .usingResource(subFolder1) - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp() - .usingResource(subFolder2) - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp() - .usingResource(subFolder3) - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp() - .usingResource(testFile1) - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp() - .usingResource(testFile2) - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp() - .usingResource(testFile3) - .assertThat().doesNotExistInRepo().and() - .assertThat().doesNotExistInFtp(); - } - - /** - * Scenario 28 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a public test site - * 3. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder - * 4. Using CMIS, U1 checks out a document from parent folder - * 5. Using CMIS, U1 deletes parent folder (deleteTree) - * 6. Using WebDAV, U1 verifies that parent folder and all children are NOT present in Repo and WebDAV - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using CMIS.") - public void deleteParentFolderWithCheckoutFileInUsingCMIS() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a public test site"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("3. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder"); - FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); - FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); - FileModel ftpTestFile = FileModel.getRandomFileModel(FileType.MSWORD, "file 4 content"); - - testFolder1 = FolderModel.getRandomFolderModel(); - cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo(); - cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile) - .assertThat().existsInRepo(); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(ftpTestFile) - .assertThat().existsInFtp().assertThat().existsInRepo(); - - FolderModel cmisTestFolder = FolderModel.getRandomFolderModel(); - FolderModel webdavTestFolder = FolderModel.getRandomFolderModel(); - FolderModel ftpTestFolder = FolderModel.getRandomFolderModel(); - - cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder) - .assertThat().existsInRepo(); - webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - ftpProtocol.usingResource(testFolder1).createFolder(ftpTestFolder) - .assertThat().existsInFtp().assertThat().existsInRepo(); - - cmisAPI.usingResource(testFolder1).assertThat() - .hasChildren(cmisTestFile, webdavTestFile, ftpTestFile, cmisTestFolder, webdavTestFolder, ftpTestFolder); - - STEP("Step 4: Using CMIS, U1 checks out a document from parent folder"); - cmisAPI.usingResource(webdavTestFile).checkOut().assertThat().documentIsCheckedOut(); - - STEP("Step 5: Using CMIS, U1 deletes parent folder (deleteTree)"); - - cmisAPI.usingResource(testFolder1).deleteFolderTree() - .assertThat().doesNotExistInRepo(); - STEP("Step 6. Using WebDAV, U1 verifies that parent folder and all children are not present"); - webDavProtocol.usingResource(testFolder1).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() - .and().usingResource(cmisTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() - .and().usingResource(webdavTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() - .and().usingResource(ftpTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() - .and().usingResource(cmisTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() - .and().usingResource(webdavTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() - .and().usingResource(ftpTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav(); - } - - /** - * Scenario 29 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a public test site - * 3. Using FTP U1 creates a parent folder in public site's document library - * 4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder - * 5. Using CMIS, U1 checks out a document from parent folder - * 6. Using WebDAV, U1 deletes parent folder (deleteFolder) - * 7. Using FTP, U1 verifies that parent folder and all children are NOT present in Repo and FTP - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using WebDAV.") - public void deleteParentFolderWithCheckoutFileInUsingWebDAV() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a public test site"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("3. Using FTP U1 creates a parent folder"); - testFolder1 = FolderModel.getRandomFolderModel(); - ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo(); - - STEP("4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder"); - FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); - FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); - FileModel ftpTestFile = FileModel.getRandomFileModel(FileType.MSWORD, "file 4 content"); - - cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile) - .assertThat().existsInRepo(); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - ftpProtocol.usingResource(testFolder1).createFile(ftpTestFile) - .assertThat().existsInFtp().assertThat().existsInRepo(); - - FolderModel cmisTestFolder = FolderModel.getRandomFolderModel(); - FolderModel webdavTestFolder = FolderModel.getRandomFolderModel(); - - cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder) - .assertThat().existsInRepo(); - webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder).assertThat().existsInWebdav() - .and().assertThat().existsInRepo(); - - cmisAPI.usingResource(testFolder1).assertThat().hasChildren(cmisTestFile, webdavTestFile, ftpTestFile, cmisTestFolder, webdavTestFolder); - - STEP("Step 5: Using CMIS, U1 checks out a document from parent folder"); - cmisAPI.usingResource(cmisTestFile).checkOut().assertThat().documentIsCheckedOut(); - - STEP("Step 6: Using WebDAV, U1 deletes parent folder (deleteFolder)"); - webDavProtocol.usingResource(testFolder1).assertThat().existsInRepo().and().assertThat().existsInWebdav() - .and().assertThat().hasFiles(cmisTestFile, webdavTestFile, ftpTestFile) - .and().assertThat().hasFolders(cmisTestFolder, webdavTestFolder) - .then().usingResource(testFolder1).delete() - .assertThat().doesNotExistInWebdav().assertThat().doesNotExistInRepo(); - - STEP("Step 7. Using FTP, U1 verifies that parent folder and all children are not present"); - ftpProtocol.usingResource(testFolder1).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() - .and().usingResource(cmisTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() - .and().usingResource(webdavTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() - .and().usingResource(ftpTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() - .and().usingResource(cmisTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() - .and().usingResource(webdavTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp(); - } - - /** - * Scenario 30 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a public test site - * 3. Using WebDAV U1 creates a parent folder in public site's document library - * 4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder - * 5. Using CMIS, U1 checks out a document from parent folder - * 6. Using FTP, U1 deletes parent folder (deleteDirectory) - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using FTP.") - public void deleteParentFolderWithCheckoutFileInUsingFTP() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a public test site"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("3. Using WebDAV U1 creates a parent folder"); - testFolder1 = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo().assertThat() - .existsInWebdav(); - - STEP("4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder"); - FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); - FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); - - cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile) - .assertThat().existsInRepo(); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - - FolderModel cmisTestFolder = FolderModel.getRandomFolderModel(); - FolderModel webdavTestFolder = FolderModel.getRandomFolderModel(); - FolderModel ftpTestFolder = FolderModel.getRandomFolderModel(); - - cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder) - .assertThat().existsInRepo(); - webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFolder(ftpTestFolder) - .assertThat().existsInFtp().assertThat().existsInRepo(); - - cmisAPI.usingResource(testFolder1).assertThat() - .hasChildren(cmisTestFile, webdavTestFile, cmisTestFolder, webdavTestFolder, ftpTestFolder); - - STEP("Step 5: Using CMIS, U1 checks out a document from parent folder"); - cmisAPI.usingResource(webdavTestFile).checkOut().assertThat().documentIsCheckedOut(); - - STEP("Step 6: Using FTP, U1 deletes parent folder (deleteDirectory)"); - ftpProtocol.usingResource(testFolder1).delete() - .and().assertThat().doesNotExistInFtp().and().assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 32 - Document updates - * - * 1. Using CMIS create 2 test users: U1 and U2 - * 2. Using CMIS and RestAPI U1 creates a public test site and U2 user is added with collaborator role - * 3. Using WebDAV U1 creates a folder in his public site's document library - * 4. Using WebDAV U1 creates a document inside the above folder - * 5. Using RestAPI U2 adds the document to favorites - * 6. Using CMIS U1 adds content to document - * 7. Using WebDAV U2 validates document's content - * 8. Using WebDAV U2 updates content from document - * 9. Using CMIS U2 validates document's content - * 10. Using WebDAV U1 deletes the file - * 11. Using RestAPI U1 deletes the folder - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user with collaborator role can update document content in a public site.") - public void usersCanUpdateDocumentContentInsideAPublicSite() throws Exception - { - String originalContent = "originalContent"; - String updatedContent = "updatedContent"; - testFolder1 = FolderModel.getRandomFolderModel(); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - STEP("1. Using CMIS create 2 test users: U1 and U2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS and RestAPI U1 creates a public test site and U2 user is added with collaborator role"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - testUser2.setUserRole(UserRole.SiteCollaborator); - restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2); - - STEP("3. Using WebDAV U1 creates a folder in his public site's document library"); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1) - .and().assertThat().existsInRepo(); - - STEP("4. Using WebDAV U1 creates a document inside the above folder"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1) - .and().assertThat().existsInWebdav() - .and().assertThat().existsInRepo(); - - STEP("5. Using RestAPI U2 adds the document to favorites"); - restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFolderToFavorites(testFolder1); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - STEP("6. Using CMIS U1 adds content to document"); - cmisAPI.authenticateUser(testUser1).usingResource(testFile1) - .and().assertThat().existsInRepo() - .and().update(originalContent); - - STEP("7. Using WebDAV U2 validates document's content"); - webDavProtocol.authenticateUser(testUser2).usingResource(testFile1).assertThat().contentIs(originalContent); - - STEP("8. Using WebDAV U2 updates content from document"); - webDavProtocol.usingUser(testUser2).usingResource(testFile1) - .assertThat().existsInRepo() - .and().update(updatedContent); - - STEP("9. Using CMIS U2 validates document's content"); - cmisAPI.authenticateUser(testUser2).usingResource(testFile1).assertThat().contentIs(updatedContent); - - STEP("10. Using WebDAV U1 deletes the file"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete() - .and().assertThat().doesNotExistInRepo(); - - STEP("11. Using WebDAV U1 deletes the folder"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).delete() - .and().assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 33 - Document likes - * - * 1. Using CMIS create 2 test users: U1 and U2 - * 2. Using RestAPI U1 creates a public test site and U2 user is added with contributor role - * 3. Using WebDAV U1 creates a folder in his public site's document library - * 4. Using WebDAV U1 creates a document1 inside the above folder - * 5. Using WebDAV U2 creates a document2 inside folder - * 6. Using RestAPI U2 likes document1 - * 7. Using RestAPI U1 likes document2 - * 8. Using RestAPI U1 dislikes document2 - * 9. Using RestAPI U2 add to favorites document1 - * 10. Using CMIS U1 delete document1 - * 11. Using CMIS U2 delete the folder - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = {CmisPermissionDeniedException.class, CmisUnauthorizedException.class} ) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user with contributor role can like/favorite a document in a public site.") - public void usersCanLikeADocumentInPublicSite() throws Exception - { - STEP("1. Using CMIS create 2 test users: U1 and U2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. Using RestAPI U1 creates a public test site and U2 user is added with contributor role"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - testUser2.setUserRole(UserRole.SiteContributor); - restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2); - - STEP("3. Using WebDAV U1 creates a folder in his public site's document library"); - testFolder1 = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) - .createFolder(testFolder1).assertThat().existsInWebdav() - .and().assertThat().existsInRepo(); - - STEP("4. Using WebDAV U1 creates a document1 inside the above folder"); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - webDavProtocol.usingResource(testFolder1).createFile(testFile1) - .assertThat().existsInRepo() - .and().assertThat().existsInWebdav(); - - STEP("5. Using WebDAV U2 creates a document2 inside folder"); - testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - webDavProtocol.authenticateUser(testUser2) - .usingResource(testFolder1).createFile(testFile2).assertThat().existsInRepo() - .and().assertThat().existsInWebdav(); - - STEP("6. Using RestAPI U2 likes document1"); - RestRatingModel returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).likeDocument(); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - STEP("7. Using RestAPI U1 likes document2"); - returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile2).likeDocument(); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true") - .and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - STEP("8. Using RestAPI U1 dislikes document2"); - restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile2).deleteLikeRating(); - restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - STEP("9. Using RestAPI U2 add to favorites document1"); - RestPersonFavoritesModel restPersonFavoritesModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(testFile1); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - restPersonFavoritesModel.assertThat().field("targetGuid").is(testFile1.getNodeRefWithoutVersion()); - - STEP("10. Using CMIS U1 delete document1"); - cmisAPI.authenticateUser(testUser1).usingResource(testFile1).delete() - .and().assertThat().doesNotExistInRepo(); - - restAPI.withCoreAPI().usingResource(testFile1).getLikeRating(); - restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef())); - - RestPersonFavoritesModelsCollection userFavorites = restAPI.withCoreAPI().usingAuthUser().getFavorites(); - restAPI.assertStatusCodeIs(HttpStatus.OK); - userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); - - STEP("11. Using CMIS U2 delete the folder. With Contributor role, U2 does not have permission to delete files/folders created by others."); - cmisAPI.authenticateUser(testUser2).usingResource(testFolder1).assertThat().doesNotHaveFile(testFile1) - .and().assertThat().hasFiles(testFile2) - .and().usingResource(testFile2).delete() - .and().usingResource(testFolder1).delete(); - } - - /** - * Scenario 34 - Document ratings - * - * 1. Using CMIS create 2 test users: U1 and U2 - * 2. Using RestAPI U1 creates a public test site and U2 user is added with collaborator role - * 3. Using CMIS U1 creates a new folder in site - * 4. Using WebDAV U2 creates file1 in public site document library - * 5. Using WebDAV U1 creates a file2 in public site document library - * 6. Using RestAPI U2 rates with 5 stars file2 - * 7. Using RestAPI U1 rates with 1 star file1 - * 8. Using RestAPI U2 likes file1 - * 9. Using RestAPI U2 removes the rating of 5 stars for file2 - * 10. Using WebDAV U1 delete file1. Using RestAPI get ratings of file1. - * 11. Using WebDAV U1 delete the folder - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify user with collaborator role can rate a document in a public site.") - public void usersCanRateADocumentInPublicSite() throws Exception - { - RestRatingModel returnedRatingModel; - - STEP("1. Using CMIS create 2 test users: U1 and U2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. Using RestAPI U1 creates a public test site and U2 user is added with collaborator role"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - testUser2.setUserRole(UserRole.SiteCollaborator); - restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2); - - STEP("3. Using CMIS U1 creates a new folder in site"); - testFolder1 = FolderModel.getRandomFolderModel(); - cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic) - .createFolder(testFolder1).assertThat().existsInRepo(); - - STEP("4. Using WebDAV U2 creates file1 in public site document library"); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - webDavProtocol.authenticateUser(testUser2).usingResource(testFolder1) - .createFile(testFile1).assertThat().existsInRepo() - .and().assertThat().existsInWebdav(); - - STEP("5. Using WebDAV U1 creates a file2 in public site document library"); - testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) - .usingResource(testFolder1).createFile(testFile2).assertThat().existsInRepo(); - - STEP("6. Using RestAPI U2 rates with 5 stars file2"); - returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile2) - .rateStarsToDocument(5); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - STEP("7. Using RestAPI U1 rates with 1 star file1"); - returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile1) - .rateStarsToDocument(1); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("1").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - STEP("8. Using RestAPI U2 likes file1"); - returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1) - .likeDocument(); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - STEP("9. Using RestAPI U2 removes the rating of 5 stars for file2"); - restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile2).deleteFiveStarRating(); - restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT); - - returnedRatingModel = restAPI.withCoreAPI().usingResource(testFile2).getFiveStarRating(); - restAPI.assertStatusCodeIs(HttpStatus.OK); - returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); - - STEP("10. Using WebDAV U1 delete file1. Using RestAPI get ratings of file1."); - webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete() - .and().assertThat().doesNotExistInRepo() - .and().assertThat().doesNotExistInWebdav(); - - restAPI.withCoreAPI().usingResource(testFile1).getLikeRating(); - restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef())); - - restAPI.withCoreAPI().usingResource(testFile1).getFiveStarRating(); - restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef())); - - STEP("11. Using WebDAV U1 delete the folder"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).assertThat().hasFiles(testFile2) - .and().usingResource(testFolder1).delete() - .and().assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 35 - * 1. Using CMIS create 2 test user: U1 and U2 - * 2. Using CMIS U1 creates a public test site - * 3. Using FTP U1 creates a folder in public site's document library: folder1 - * 4. Using WebDAV U1 creates inside folder1 a new folder: folder2 - * 5. Using WebDAV U1 creates inside folder2 a new folder: folder3 - * 6. Using CMIS U1 creates inside folder1 a new file: file1 - * 7. Using WebDAV U1 creates inside folder2 a new file: file2 - * 8. Using FTP U1 creates inside folder3 a new file: file3 - * 9. Using WebDAV U1 deletes file1 - * 10. Using IMAP U1 deletes file2 - * 11. Using WebDAV U1 updates content of file3 - * 12. Using RestAPI U1 adds a comment to file3 - * 13. Using RestAPI U1 likes file3 and user U2 rates file3 - * 14. Using CMIS U1 deletes file3 - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "File handling - perform actions: create, delete, add comment, like and rate, update file content ") - public void fileHandlingCreateUpdateContentDeleteLikeAndRate() throws Exception - { - STEP("1. Using CMIS create 1 test user: U1 and U2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. U1 creates a public test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); - - STEP("3. Using FTP U1 creates folder: folder1"); - FolderModel folder1 = FolderModel.getRandomFolderModel(); - ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder1) - .assertThat().existsInRepo(); - - STEP("4. Using WebDAV U1 creates folder2 inside folder1"); - FolderModel folder2 = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1).usingResource(folder1).createFolder(folder2); - - STEP("5. Using webDAV U1 creates folder3 inside folder2"); - FolderModel folder3 = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1).usingResource(folder2).createFolder(folder3); - - STEP("6. Using CMIS U1 creates file1 inside folder1"); - FileModel file1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); - cmisAPI.authenticateUser(testUser1).usingResource(folder1).createFile(file1) - .assertThat().existsInRepo(); - - STEP("7. Using webDAV U1 creates file2 inside folder2"); - FileModel file2 = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); - webDavProtocol.authenticateUser(testUser1).usingResource(folder2).createFile(file2) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - - STEP("8. Using FTP U1 creates file3 inside folder3"); - FileModel file3 = FileModel.getRandomFileModel(FileType.MSWORD, "file 3 content"); - ftpProtocol.authenticateUser(testUser1).usingResource(folder3).createFile(file3) - .assertThat().existsInRepo(); - - STEP("9. Using webDAV U1 deletes file1"); - webDavProtocol.authenticateUser(testUser1).usingResource(file1).delete() - .assertThat().doesNotExistInRepo().and().assertThat().doesNotExistInWebdav(); - - STEP("10. Using IMAP U1 deletes file2"); - imapProtocol.authenticateUser(testUser1).usingResource(file2).deleteMessage() - .and().usingResource(file2).assertThat().doesNotExistInRepo(); - - STEP("11. Using WebDAV U1 update content of file3"); - webDavProtocol.authenticateUser(testUser1) - .usingResource(file3).assertThat().existsInRepo() - .update(newContent).assertThat().contentIs(newContent); - - STEP("12. Using RestAPI U1 adds a comment to file3"); - String comment = RandomData.getRandomName("comment1"); - file3.setNodeRef(dataContent.usingUser(testUser1).usingSite(testSitePublic) - .usingResource(folder3).usingResource(file3).getNodeRef()); - RestCommentModel commentModel = restAPI.authenticateUser(testUser1).withCoreAPI() - .usingResource(file3).addComment(comment); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - commentModel.assertThat().field("content").isNotEmpty() - .and().field("content").is(comment); - - STEP("13. Using RestAPI U1 likes file3 and user U2 rates file3"); - returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(file3).likeDocument(); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); - - returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI() - .usingResource(file3).rateStarsToDocument(5); - restAPI.assertStatusCodeIs(HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); - - STEP("14. Using CMIS U1 deletes file3"); - cmisAPI.authenticateUser(testUser1).usingResource(file3).delete() - .assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 37 - * 1. Using CMIS creates 2 users: U1 and U - * 2. U1 creates a public test site using CMIS - * 3. Using CMIS U1 creates folder: folder1 - * 4. Using WebDAV U1 creates folder2 and folder3 inside folder1 - * 5. Using FTP U1 creates file1 inside folder1 - * 6. Using CMIS U1 copies file1 to folder2 - * 7. Using WebDAV U1 update content of file1 from folder2 - * 8. Using FTP U1 tries to move file1 from folder2 to folder1 - * 9. Using WebDAV U1 updates content of file1 from folder1 - * 10. Using RestAPI U1 adds file1 to favorites - * 11. Using RestAPI U1 likes file1 and U2 user rates file1 - * 12. Using CMIS U1 moves file1 from folder1 to folder3 - * 13. Using CMIS/RestAPI U1 checks that content, favorites and ratings are kept - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "File handling - perform actions: copy, move, add/update content, favorites, like and rate") - public void fileHandlingCopyMoveAddUpdateContentFavoritesLikeAndRate() throws Exception - { - STEP("1. Using CMIS creates 2 users: U1 and U2"); - testUser1 = dataUser.createRandomTestUser(); - testUser2 = dataUser.createRandomTestUser(); - - STEP("2. U1 creates a public test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("3. Using CMIS U1 creates folder: folder1"); - FolderModel folder1 = FolderModel.getRandomFolderModel(); - cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder1) - .assertThat().existsInRepo(); - - STEP("4. Using WebDAV U1 creates folder2 and folder3 inside folder1"); - FolderModel folder2 = FolderModel.getRandomFolderModel(); - FolderModel folder3 = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1) - .usingResource(folder1).createFolder(folder2).and().assertThat().existsInWebdav() - .usingResource(folder1).createFolder(folder3).and().assertThat().existsInWebdav(); - - STEP("5. Using FTP U1 creates file1 inside folder1"); - FileModel file1 = FileModel.getRandomFileModel(FileType.MSWORD2007, "tasTesting"); - ftpProtocol.authenticateUser(testUser1).usingResource(folder1).createFile(file1) - .assertThat().existsInRepo(); - - STEP("6. Using CMIS U1 copies file1 to folder2"); - FileModel copiedFile = new FileModel(file1); - cmisAPI.authenticateUser(testUser1).usingResource(file1).copyTo(folder2); - copiedFile.setCmisLocation(cmisAPI.getLastResource()); - cmisAPI.usingResource(folder2).assertThat().hasFiles(file1); - - STEP("7. Using WebDAV U1 update content of file1 from folder2"); - webDavProtocol.usingResource(copiedFile).assertThat().existsInRepo() - .update(newContent).assertThat().contentIs(newContent); - - STEP("8. Using FTP U1 tries to move file1 from folder2 to folder1"); - ftpProtocol.authenticateUser(testUser1) - .usingResource(copiedFile).moveTo(folder1).assertThat().existsInRepo(); - Assert.assertTrue(ftpProtocol.usingResource(folder1).getFiles().size() == 1); - - STEP("9. Using WebDAV U1 updates content of file1 from folder1"); - webDavProtocol.usingResource(file1).update("content folder1") - .assertThat().contentIs("content folder1"); - - STEP("10. Using RestAPI U1 adds file1 to favorites"); - file1.setNodeRef(dataContent.usingUser(testUser1).usingSite(testSitePublic) - .usingResource(folder1).usingResource(file1).getNodeRef()); - - restPersonFavoritesModel = restAPI.authenticateUser(testUser1).withCoreAPI() - .usingAuthUser().addFileToFavorites(file1); - restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED); - restPersonFavoritesModel.assertThat().field("targetGuid").is(file1.getNodeRefWithoutVersion()); - - STEP("11. Using RestAPI U1 likes file1 and U2 user rates file1"); - returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI() - .usingResource(file1).likeDocument(); - restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes") - .and().field("aggregate").isNotEmpty(); - - returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI() - .usingResource(file1).rateStarsToDocument(5); - restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - - STEP("12. Using CMIS U1 moves file1 from folder1 to folder3"); - cmisAPI.usingSite(testSitePublic).usingResource(file1).moveTo(folder3) - .and().assertThat().existsInRepo(); - - STEP("13. Using CMIS/RestAPI U1 checks that content, favorites and ratings are kept"); - returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") - .and().field("aggregate").isNotEmpty(); - restPersonFavoritesModel.assertThat().field("targetGuid").is(file1.getNodeRefWithoutVersion()); - } - - /** - * Scenario 38 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a new document in Share - * 3. Using WebDAV U1 creates a new document in User Home - * 4. Using WebDAV U1 updates both documents - * 5. Verify if only first document's version is increased using CMIS - * 6. Verify if content is updated using WebDav - * 7. Verify if the size of the document is increased - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify document versioning after appending content using WebDAV.") - public void checkDocumentVersionAfterAppendingContent() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a new document in Share"); - FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); - cmisAPI.authenticateUser(testUser1) - .usingShared().createFile(cmisTestFile) - .assertThat().existsInRepo(); - - STEP("3. Using WebDAV U1 creates a new document in User Home"); - FileModel webDAVTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 2 content"); - webDavProtocol.authenticateUser(testUser1) - .usingUserHome().createFile(webDAVTestFile) - .assertThat().existsInWebdav().and() - .assertThat().existsInRepo(); - - STEP("4. Using WebDAV U1 updates both documents"); - webDavProtocol.usingResource(cmisTestFile).update("cmis file content") - .usingResource(webDAVTestFile).update("WebDAV file content"); - - STEP("5. Verify if only first document's version is increased using CMIS"); - cmisAPI.usingResource(cmisTestFile).assertThat().documentHasVersion(1.1) - .usingResource(webDAVTestFile).assertThat().documentHasVersion(1.0); - - STEP("6. Verify if content is updated using WebDav"); - webDavProtocol.authenticateUser(testUser1) - .usingResource(cmisTestFile).assertThat().contentIs("cmis file content") - .usingResource(webDAVTestFile).assertThat().contentIs("WebDAV file content"); - - STEP("7. Verify if the size of the document is increased"); - cmisAPI.usingResource(cmisTestFile).assertThat().contentLengthIs(17) - .usingResource(webDAVTestFile).assertThat().contentLengthIs(19); - } - - /** - * Scenario 40 - * 1. Using CMIS create test user: U1 - * 2. U1 creates a private test site using CMIS - * 3. Using WebDAV U1 creates a folder - * 4. Using WebDAV U1 creates a file inside the folder - * 5. Using CMIS, check out the document - * 6. Using CMIS verify if PWC is created - * 7. Using CMIS check in document with content - * 8. Using CMIS verify that version does not increase - * 9. Using CMIS verify new content is added to document - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify increased version and new content of a file that was check out then check in.") - public void verifyIncreasedVersionAndNewContentOfCheckInDocument() throws Exception - { - STEP("Step 1. Using CMIS create test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("Step 2. U1 creates a private test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createPrivateRandomSite(); - - STEP("Step 3. Using WebDAV U1 creates a folder"); - FolderModel folder = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder); - - STEP("Step 4. Using WebDAV U1 creates a file inside the folder"); - FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content"); - webDavProtocol.authenticateUser(testUser1).usingResource(folder).createFile(file) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - - STEP("Step 5: Using CMIS, check out the document and verify document version"); - cmisAPI.authenticateUser(testUser1).usingResource(file).checkOut() - .assertThat().documentIsCheckedOut(); - - STEP("Step 6: Using CMIS verify if PWC is created"); - FileModel filePWC = cmisAPI.usingResource(file).withCMISUtil().getPWCFileModel(); - cmisAPI.usingResource(filePWC).assertThat().existsInRepo(); - - STEP("Step 7: Using CMIS check in document with content"); - String newContent = "new major content"; - cmisAPI.usingResource(folder).assertThat().folderHasCheckedOutDocument(file); - cmisAPI.usingResource(file).prepareDocumentForCheckIn() - .withMajorVersion() - .withContent(newContent) - .checkIn().refreshResource() - .and().assertThat().documentIsNotCheckedOut(); - - STEP("Step 8: Using CMIS verify that version does not increase"); - cmisAPI.usingResource(file).assertThat().documentHasVersion(1.0); - - STEP("Step 9: Using CMIS verify new content is added to document"); - cmisAPI.usingResource(file).assertThat().contentIs(newContent); - } - - /** - * Scenario 41 - * 1. Using CMIS create test user: U1 - * 2. U1 creates a private test site using CMIS - * 3. Using WebDAV U1 creates a folder - * 4. Using WebDAV U1 creates a file inside the folder - * 5. Using CMIS, check out the document - * 6. Using CMIS verify if PWC is created - * 7. Using CMIS, cancel check out - * 8. Using CMIS, verify original document has version 1.0 - * 9. Using CMIS, verify original document has same content - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Verify that version and the content of a file are not changed if the checkout is canceled.") - public void verifyVersionAndContentOfACanceledCheckoutDocument() throws Exception - { - STEP("Step 1. Using CMIS create test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("Step 2. U1 creates a private test site using CMIS"); - testSitePublic = dataSite.usingUser(testUser1).createPrivateRandomSite(); - - STEP("Step 3. Using WebDAV U1 creates a folder"); - FolderModel folder = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder); - - STEP("Step 4. Using WebDAV U1 creates a file inside the folder"); - FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content"); - webDavProtocol.authenticateUser(testUser1).usingResource(folder).createFile(file) - .assertThat().existsInWebdav().assertThat().existsInRepo(); - - STEP("Step 5: Using CMIS, check out the document"); - cmisAPI.authenticateUser(testUser1).usingResource(file).checkOut(); - - STEP("Step 6: Using CMIS verify if PWC is created"); - FileModel filePWC = cmisAPI.usingResource(file).withCMISUtil().getPWCFileModel(); - cmisAPI.usingResource(filePWC).assertThat().existsInRepo(); - - STEP("Step 7: Using CMIS, cancel check out"); - cmisAPI.usingResource(file).cancelCheckOut().then() - .assertThat().documentIsNotCheckedOut(); - - STEP("Step 8: Using CMIS, verify original document has version 1.0"); - cmisAPI.usingResource(file).assertThat().isNotPrivateWorkingCopy() - .then().assertThat().documentHasVersion(1.0); - - STEP("Step 9: Using CMIS, verify original document has same content"); - cmisAPI.usingResource(file).assertThat().contentIs("file content"); - } - - /** - * Scenario 42 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a file: file - * 3. Using WebDAV U1 renames file and verify if the new document exists - * 4. Using FTP verify old document does not exists - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Edit document name and verify document with new name") - public void renameDocument() throws Exception - { - STEP("1. Using CMIS create test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates file"); - FileModel file = FileModel.getRandomFileModel(FileType.PDF, "file content"); - cmisAPI.authenticateUser(testUser1).usingUserHome().createFile(file) - .assertThat().existsInRepo(); - - STEP("3. Using WebDAV U1 renames file and verify if the new document exists"); - FileModel oldFile = new FileModel(file); - webDavProtocol.authenticateUser(testUser1).usingResource(file).rename(renamePrefix + file.getName()) - .and().assertThat().existsInRepo().and().assertThat().existsInWebdav(); - - STEP("4. Using FTP verify old document does not exists"); - ftpProtocol.authenticateUser(testUser1).usingResource(oldFile) - .assertThat().doesNotExistInRepo() - .and().assertThat().doesNotExistInFtp(); - } - - /** - * Scenario 43 - * 1. Using CMIS create test user: U1 - * 2. Using WebDAV U1 creates a file using shared - * 3. Using webDAV append content to document - * 4. Using CMIS, verify original document has version 1.0 - * 5. Using CMIS delete document - * 6. Using WebDAV, verify document is deleted - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, - description = "Delete document after append content and verify document version.") - public void deleteDocumentAfterAppendContent() throws Exception - { - STEP("Step 1. Using CMIS create test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("Step 2. Using WebDAV U1 creates a file using shared"); - FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content"); - webDavProtocol.authenticateUser(testUser1).usingUserHome().createFile(file) - .assertThat().existsInRepo(); - - STEP("Step 3. Using webDAV append content to document"); - String newContentToAppend = " - append this text to the file"; - webDavProtocol.authenticateUser(testUser1).usingResource(file).assertThat().contentIs("file content") - .then().update(file.getContent() + newContentToAppend) - .assertThat().contentIs(file.getContent() + newContentToAppend); - - STEP("Step 4: Using CMIS, verify original document has version 1.0"); - cmisAPI.authenticateUser(testUser1).usingResource(file).assertThat().isNotPrivateWorkingCopy() - .then().assertThat().documentHasVersion(1.0); - - STEP("Step 4: Using CMIS, delete document"); - cmisAPI.usingResource(file).assertThat().existsInRepo().delete(); - - STEP("Step 5: Using WebDAV, verify document is deleted"); - webDavProtocol.authenticateUser(testUser1).usingResource(file).assertThat().doesNotExistInWebdav() - .and().assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 44 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a public test site - * 3. Using WebDAV U1 creates a new file in User Home - * 4. Using WebDAV U1 creates another file in public site document library. - * 5. Using CMIS U1 creates a relationship between documents - * 6. Verify if relationship is created - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify if relationship is created between 2 items using CMIS.") - public void checkRelationshipBetween2Files() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a public test site"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("3. Using WebDAV U1 creates a new file in User Home"); - FileModel sourceFile= FileModel.getRandomFileModel(FileType.PDF, "file content"); - webDavProtocol.authenticateUser(testUser1).usingUserHome() - .createFile(sourceFile).assertThat().existsInRepo(); - - STEP("4. Using WebDAV U1 creates another file in public site document library."); - FileModel targetFile= FileModel.getRandomFileModel(FileType.PDF, "file content"); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) - .createFile(targetFile).assertThat().existsInRepo(); - - STEP("5. Using CMIS U1 creates a relationship between documents. 6. Verify if relationship is created"); - cmisAPI.authenticateUser(testUser1).usingResource(sourceFile).createRelationshipWith(targetFile) - .assertThat().objectHasRelationshipWith(targetFile); - } - - /** - * Scenario 46 - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates an imap test site - * 3. Using CMIS U1 creates cmisFolder in Shared - * 4. Using IMAP U1 creates parentFolder in private site document library. - * 5. Using FTP U1 creates a subfolder in parentFolder - * 6. Using WebDAV U1 creates a webdavFolder in User Home - * 7. Using WebDAV U1 creates a document in parentFolder - * 8. Using CMIS U1 adds document to cmisFolder, subfolder, webdavFolder - * 9. Using WebDAV verify document is present in all folders - * 10. Using CMIS U1 removes document from subFolder - * 11. Using WebDAV verify document is not present in subFolder - * 12. Using FTP U1 deletes original document from parentFolder - * 13. Using CMIS verify document does not exist - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify parents list for an object using CMIS.") - public void addAndRemoveDocumentFromFolders() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates an imap test site"); - testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); - - STEP("3. Using CMIS U1 creates cmisFolder in Shared"); - FolderModel cmisFolder = FolderModel.getRandomFolderModel(); - cmisAPI.authenticateUser(testUser1) - .usingShared().createFolder(cmisFolder) - .assertThat().existsInRepo(); - - STEP("4. Using IMAP U1 creates parentFolder in private site document library."); - FolderModel parentFolder = FolderModel.getRandomFolderModel(); - imapProtocol.authenticateUser(testUser1) - .usingSite(testSitePublic).createFolder(parentFolder) - .assertThat().existsInRepo(); - - STEP("5. Using FTP U1 creates a subfolder in parentFolder"); - FolderModel subFolder = FolderModel.getRandomFolderModel(); - ftpProtocol.authenticateUser(testUser1) - .usingResource(parentFolder).createFolder(subFolder) - .assertThat().existsInRepo(); - - STEP("6. Using WebDAV U1 creates a webdavFolder in User Home"); - FolderModel webdavFolder = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1) - .usingUserHome().createFolder(webdavFolder) - .assertThat().existsInRepo(); - - STEP("7. Using WebDAV U1 creates a document in parentFolder"); - testFile1= FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); - webDavProtocol.authenticateUser(testUser1) - .usingResource(parentFolder).createFile(testFile1) - .assertThat().existsInRepo(); - - STEP("8. Using CMIS U1 adds document to cmisFolder, subfolder, webdavFolder"); - cmisAPI.usingResource(testFile1) - .addDocumentToFolder(cmisFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName()) - .addDocumentToFolder(subFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), subFolder.getName()) - .addDocumentToFolder(webdavFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), subFolder.getName(), webdavFolder.getName()); - - STEP("9. Using WebDAV verify document is present in all folders"); - FileModel fileAddedInCMISFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); - fileAddedInCMISFolder.setCmisLocation(Utility.buildPath(cmisFolder.getCmisLocation(), testFile1.getName())); - - FileModel fileAddedInSubFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); - fileAddedInSubFolder.setCmisLocation(Utility.buildPath(subFolder.getCmisLocation(), testFile1.getName())); - - FileModel fileAddedInWebDAVFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); - fileAddedInWebDAVFolder.setCmisLocation(Utility.buildPath(webdavFolder.getCmisLocation(), testFile1.getName())); - - webDavProtocol.usingResource(fileAddedInCMISFolder).assertThat().existsInWebdav() - .usingResource(fileAddedInSubFolder).assertThat().existsInWebdav() - .usingResource(fileAddedInWebDAVFolder).assertThat().existsInWebdav(); - - STEP("10. Using CMIS U1 removes document from subFolder"); - cmisAPI.usingResource(testFile1).removeDocumentFromFolder(subFolder) - .assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), webdavFolder.getName()); - - STEP("11. Using WebDAV verify document is not present in subFolder"); - webDavProtocol.usingResource(testFile1).assertThat().existsInWebdav() - .usingResource(fileAddedInCMISFolder).assertThat().existsInWebdav() - .usingResource(fileAddedInSubFolder).assertThat().doesNotExistInWebdav() - .usingResource(fileAddedInWebDAVFolder).assertThat().existsInWebdav(); - - STEP("12. Using FTP U1 deletes original document from parentFolder"); - ftpProtocol.usingResource(testFile1).delete().assertThat().doesNotExistInFtp(); - - STEP("13. Using CMIS verify document does not exist"); - cmisAPI.usingResource(fileAddedInCMISFolder).assertThat().doesNotExistInRepo() - .usingResource(fileAddedInWebDAVFolder).assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 47 - Delete many documents - * - * 1. Using CMIS create test user: U1 - * 2. Using CMIS U1 creates a public test site - * 3. Using CMIS and WebDAV U1 creates parentFolder1, doc1 and doc2 in document library - * 4. Using WebDAV and FTP U1 creates inside parentFolder1: childDoc1 to childDoc5 - * 5. Using IMAP bulk delete doc1 and doc2 - * 6. Using CMIS verify that doc1 and doc2 are deleted - * 7. Using IMAP delete childDoc1 to childDoc4 - * 8. Using WebDAV and FTP verify if docs are deleted from their folders - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION, - description = "Verify users can delete many documents in a public site using different protocols.") - public void usersCanDeleteManyDocuments() throws Exception - { - FolderModel parentFolder1 = FolderModel.getRandomFolderModel(); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - FileModel childDoc1, childDoc2, childDoc3, childDoc4, childDoc5; - childDoc1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - childDoc2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - childDoc3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - childDoc4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - childDoc5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - STEP("1. Using CMIS create test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a public test site"); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("3. Using CMIS and WebDAV U1 creates parentFolder1, doc1 and doc2 in document library"); - cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(parentFolder1) - .and().assertThat().existsInRepo(); - - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1) - .and().createFile(testFile2); - - STEP("4. Using WebDAV and FTP U1 creates inside parentFolder1: childDoc1 to childDoc5"); - webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder1) - .createFile(childDoc1).and().createFile(childDoc2); - - ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder1) - .createFile(childDoc3).and().createFile(childDoc4).and().createFile(childDoc5); - - STEP("5. Using IMAP bulk delete doc1 and doc2"); - imapProtocol.authenticateUser(testUser1).usingSite(testSitePublic).deleteMessage(testFile1.getName(), testFile2.getName()).assertThat().doesNotContainMessages(testFile1, testFile2); - Utility.waitToLoopTime(10); - - STEP("6. Using CMIS verify that doc1 and doc2 are deleted"); - cmisAPI.authenticateUser(testUser1) - .usingResource(testFile1).assertThat().doesNotExistInRepo() - .and().usingResource(testFile2).assertThat().doesNotExistInRepo(); - - STEP("7. Using IMAP delete childDoc1 to childDoc4"); - imapProtocol.authenticateUser(testUser1).usingResource(parentFolder1).deleteMessage(childDoc1.getName(), childDoc2.getName(), childDoc3.getName(), childDoc4.getName()) - .assertThat().doesNotContainMessages(childDoc1, childDoc2, childDoc3, childDoc4); - Utility.waitToLoopTime(10); - - STEP("8. Using WebDAV and FTP verify if docs are deleted from their folders"); - webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder1).assertThat().hasFiles(childDoc5) - .and().usingResource(childDoc1).assertThat().doesNotExistInRepo() - .and().usingResource(childDoc2).assertThat().doesNotExistInRepo(); - - ftpProtocol.authenticateUser(testUser1).usingResource(childDoc3) - .assertThat().doesNotExistInRepo() - .and().usingResource(childDoc4).assertThat().doesNotExistInRepo(); - } - - /** - * Scenario 48 - Move folder in another folder - * - * 1. Using CMIS create user u1 and public site - * 2. Using WebDAV U1 creates folder1 and folder2 - * 3. Using WebDAV U1 creates doc1 in folder1 - * 4. Using FTP U1 moves folder1 in folder2 - * 5. Using WebDAV verify that folder1 is not in the original location and is present in folder2 - * 6. Using CMIS verify if doc1 is still present in folder1 - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to move a non empty folder to another folder from the same site.") - public void moveFolderInAnotherFolder() throws Exception - { - testFolder1 = FolderModel.getRandomFolderModel(); - testFolder2 = FolderModel.getRandomFolderModel(); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - STEP("1. Using CMIS create user u1 and public site"); - testUser1 = dataUser.createRandomTestUser(); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("2. Using WebDAV U1 creates folder1 and folder2"); - webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) - .createFolder(testFolder1) - .and().assertThat().existsInRepo().and().assertThat().existsInWebdav() - .then().createFolder(testFolder2) - .and().assertThat().existsInRepo().and().assertThat().existsInWebdav(); - - STEP("3. Using WebDAV U1 creates doc1 in folder1"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1) - .and().assertThat().existsInRepo().and().assertThat().existsInWebdav() - .and().usingResource(testFolder1).assertThat().hasFiles(testFile1); - - STEP("4. Using FTP U1 moves folder1 in folder2"); - ftpProtocol.authenticateUser(testUser1) - .usingResource(testFolder1).moveTo(testFolder2) - .assertThat().existsInRepo() - .then().usingResource(testFolder1).assertThat().doesNotExistInRepo(); - - STEP("5. Using WebDAV verify that folder1 is not in the original location and is present in folder2"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).assertThat().doesNotExistInRepo() - .and().usingResource(testFolder2).assertThat().hasFolders(testFolder1); - - STEP("6. Using CMIS verify if doc1 is still present in folder1"); - FolderModel newTestFolder1 = new FolderModel(testFolder1.getName(), testFolder1.getTitle(), testFolder1.getDescription()); - newTestFolder1.setCmisLocation(Utility.buildPath(testFolder2.getCmisLocation(), testFolder1.getName())); - - FileModel newTestFile1 = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); - newTestFile1.setCmisLocation(Utility.buildPath(newTestFolder1.getCmisLocation(), testFile1.getName())); - - cmisAPI.authenticateUser(testUser1).usingResource(newTestFolder1) - .assertThat().existsInRepo() - .assertThat().hasFiles(newTestFile1); - } - - /** - * Scenario 49 - Copy folder in another folder - * - * 1. Using CMIS create user u1 and public site - * 2. Using CMIS U1 creates folder1 and folder2 - * 3. Using WebDAV U1 creates doc1 in folder1 - * 4. Using WebDAV U1 copies folder1 in folder2 - * 5. Using FTP verify that folder1 is in the original location and contains doc1 - * 6. Using WebDAV verify that folder1 is in folder2 and contains doc1 - */ - - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to copy non empty folder to another folder in the same site.") - public void copyFolderInAnotherFolder() throws Exception - { - testFolder1 = FolderModel.getRandomFolderModel(); - testFolder2 = FolderModel.getRandomFolderModel(); - testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); - - STEP("1. Using CMIS create user u1 and public site"); - testUser1 = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); - testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); - - STEP("2. Using CMIS U1 creates folder1 and folder2"); - cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic) - .createFolder(testFolder1).and().assertThat().existsInRepo().and() - .createFolder(testFolder2).and().assertThat().existsInRepo(); - - STEP("3. Using WebDAV U1 creates doc1 in folder1"); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1) - .createFile(testFile1).and().assertThat().existsInRepo() - .and().assertThat().existsInWebdav(); - - STEP("4. Using WebDAV U1 copies folder1 in folder2"); - testFolder2.setProtocolLocation(webDavProtocol.getPrefixSpace() + testFolder2.getCmisLocation()); - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).copyTo(testFolder2) - .assertThat().existsInRepo() - .then().usingResource(testFolder1).assertThat().existsInRepo(); - - STEP("5. Using FTP verify that folder1 is in the original location and contains doc1"); - ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1) - .assertThat().existsInRepo() - .and().assertThat().existsInFtp() - .and().assertThat().hasFiles(testFile1); - - STEP("6. Using WebDAV verify that folder1 is in folder2 and contains doc1"); - FolderModel newTestFolder1 = new FolderModel(testFolder1.getName(), testFolder1.getTitle(), testFolder1.getDescription()); - newTestFolder1.setCmisLocation(Utility.buildPath(testFolder2.getCmisLocation(), testFolder1.getName())); - - FileModel newTestFile1 = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); - newTestFile1.setCmisLocation(Utility.buildPath(newTestFolder1.getCmisLocation(), testFile1.getName())); - - webDavProtocol.authenticateUser(testUser1).usingResource(testFolder2) - .assertThat().hasFolders(newTestFolder1) - .and().usingResource(newTestFolder1) - .assertThat().existsInRepo().and().assertThat().existsInWebdav() - .and().assertThat().hasFiles(newTestFile1); - } - - /** - * Scenario 50 - Rename site - * - * 1. Using CMIS create one test user: U1 - * 2. Using CMIS U1 creates a moderated site - * 3. Using WebDAV U1 creates a folder in the moderated site document library - * 4. Using CMIS U1 tries to rename site - * 5. Verify that a site cannot be renamed - */ - @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = CmisRuntimeException.class, expectedExceptionsMessageRegExp = "^.*Sites can not be renamed.$") - @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify sites cannot be renamed using CMIS.") - public void renameSite() throws Exception - { - STEP("1. Using CMIS create one test user: U1"); - testUser1 = dataUser.createRandomTestUser(); - - STEP("2. Using CMIS U1 creates a moderated site"); - testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite(); - - STEP("3. Using WebDAV U1 creates a folder in the moderated site document library"); - testFolder1 = FolderModel.getRandomFolderModel(); - webDavProtocol.authenticateUser(testUser1) - .usingSite(testSiteModerated).createFolder(testFolder1) - .assertThat().existsInWebdav() - .assertThat().existsInRepo(); - - STEP("4. Using CMIS U1 tries to rename site 5. Verify that a site cannot be renamed"); - FolderModel siteFolder = new FolderModel(String.format("/Sites/%s", testSiteModerated.getId())); - cmisAPI.authenticateUser(testUser1).usingResource(siteFolder).rename("renamedSite"); - } -} +package org.alfresco.tas.integration; + +import static org.alfresco.utility.report.log.Step.STEP; + +import javax.mail.FolderNotFoundException; + +import org.alfresco.rest.model.RestCommentModel; +import org.alfresco.rest.model.RestDeploymentModel; +import org.alfresco.rest.model.RestDeploymentModelsCollection; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestPersonFavoritesModel; +import org.alfresco.rest.model.RestPersonFavoritesModelsCollection; +import org.alfresco.rest.model.RestRatingModel; +import org.alfresco.utility.Utility; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.RandomData; +import org.alfresco.utility.model.*; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisUnauthorizedException; +import org.apache.commons.lang3.RandomStringUtils; +import org.springframework.http.HttpStatus; +import org.testng.annotations.Test; + +import junit.framework.Assert; + +/** + * Created by Claudia Agache on 12/13/2016. + */ +public class IntegrationCoreTests extends IntegrationTest +{ + UserModel testUser1, testUser2; + SiteModel testSitePublic, testSiteModerated, testSitePrivate, secondPublicSite; + FolderModel testFolder1, testFolder2, parentFolder1; + private String renamePrefix = "edited-"; + FileModel testFile1, testFile2, childDoc1, childDoc2, childDoc3, childDoc4, childDoc5; + RestRatingModel returnedRatingModel; + RestPersonFavoritesModel restPersonFavoritesModel; + private String newContent = "new TAS content"; + + /** + * Scenario 22 + * 1. Using CMIS create 2 test users: u1 and u2 + * 2. U1 creates a public test site and U2 a public test site using CMIS + * 3. U1 creates a folder with a file in his public site's document library using WebDav + * 4. U1 tries to move his folder to U2 public site using IMAP + * 5. Verify folder with file is not moved. U1 is not authorized to access the public site + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = FolderNotFoundException.class) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user is not able to move a folder with a file to a public site if he is not a member of that site.") + public void moveFolderWithFileToPublicSiteByUninvitedUser() throws Exception + { + STEP("1. Using CMIS create 2 test users: u1 and u2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. U1 creates a public test site and U2 a public test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + secondPublicSite = dataSite.usingUser(testUser2).createIMAPSite(); + + STEP("3. U1 creates a folder with a file in public site's document library using WebDav"); + testFolder1 = FolderModel.getRandomFolderModel(); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file1 content"); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) + .createFolder(testFolder1).assertThat().existsInWebdav() + .usingResource(testFolder1).createFile(testFile1).assertThat().existsInRepo(); + + STEP("4. U1 tries to move his folder to U2 public site using IMAP. 5. Verify folder with file is not moved. U1 is not authorized to access the U2 public site"); + FolderModel destination = new FolderModel(Utility.buildPath("Sites", secondPublicSite.getId(), "documentLibrary")); + destination.setProtocolLocation(imapProtocol.authenticateUser(testUser2).usingSite(secondPublicSite).getLastResourceWithoutPrefix()); + imapProtocol.authenticateUser(testUser1) + .usingResource(testFolder1).moveTo(destination) + .assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 23 + * 1. Using CMIS create 1 test user: u1 + * 2. U1 creates a public test site + * 3. U1 creates a folder (parentFolder) inside public site's document library using WebDav + * 4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP + * 5. Inside parentFolder create 1 subfolder using IMAP + * 6. Delete parentFolder using CMIS + * 7. Verify folder is deleted along with all its children + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to delete parent folder along with all its children using CMIS.") + public void deleteFolderWithChildrenUsingCMIS() throws Exception + { + STEP("1. Using CMIS create 1 test user: u1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. U1 creates a public test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); + + STEP("3. U1 creates a folder (parentFolder) inside public site's document library using WebDav"); + FolderModel parentFolder = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1) + .usingSite(testSitePublic).createFolder(parentFolder) + .assertThat().existsInWebdav() + .and().assertThat().existsInRepo(); + + STEP("4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP"); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD); + FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML); + FileModel testFile4 = FileModel.getRandomFileModel(FileType.EXE); + cmisAPI.authenticateUser(testUser1).usingResource(parentFolder) + .createFile(testFile1).assertThat().existsInRepo(); + webDavProtocol.usingResource(parentFolder).createFile(testFile2) + .assertThat().existsInWebdav().and() + .assertThat().existsInRepo(); + cmisAPI.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile3) + .assertThat().existsInRepo(); + ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile4) + .assertThat().existsInFtp().and() + .assertThat().existsInRepo(); + + STEP("5. Inside parentFolder create 1 subfolder using IMAP"); + testFolder1 = FolderModel.getRandomFolderModel(); + imapProtocol.authenticateUser(testUser1) + .usingResource(parentFolder).createFolder(testFolder1) + .assertThat().existsInImap().and() + .assertThat().existsInRepo(); + + STEP("6. Delete parentFolder using CMIS 7. Verify folder is deleted along with all its children"); + cmisAPI.usingResource(parentFolder).deleteFolderTree().and().assertThat().doesNotExistInRepo() + .usingResource(testFolder1).assertThat().doesNotExistInRepo() + .usingResource(testFile1).assertThat().doesNotExistInRepo() + .usingResource(testFile2).assertThat().doesNotExistInRepo() + .usingResource(testFile3).assertThat().doesNotExistInRepo() + .usingResource(testFile4).assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 24 + * 1. Using CMIS create 1 test user: u1 + * 2. U1 creates a public test site + * 3. U1 creates a folder (parentFolder) inside public site's document library using IMAP + * 4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP + * 5. Inside parentFolder create 1 subfolder using WebDAV + * 6. Delete parentFolder using WebDAV + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to delete parent folder along with all its children using WebDAV.") + public void deleteFolderWithChildrenUsingWebDAV() throws Exception + { + STEP("1. Using CMIS create 1 test user: u1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. U1 creates a public test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); + + STEP("3. U1 creates a folder (parentFolder) inside public site's document library using IMAP"); + FolderModel parentFolder = FolderModel.getRandomFolderModel(); + imapProtocol.authenticateUser(testUser1) + .usingSite(testSitePublic).createFolder(parentFolder) + .assertThat().existsInImap().and() + .assertThat().existsInRepo(); + + STEP("4. Inside parentFolder create 4 files using CMIS, WebDAV, FTP"); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD); + FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML); + FileModel testFile4 = FileModel.getRandomFileModel(FileType.EXE); + cmisAPI.authenticateUser(testUser1).usingResource(parentFolder) + .createFile(testFile1).assertThat().existsInRepo(); + webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile2) + .assertThat().existsInWebdav().and() + .assertThat().existsInRepo(); + ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder).createFile(testFile4) + .assertThat().existsInFtp().and() + .assertThat().existsInRepo(); + + STEP("5. Inside parentFolder create 1 subfolder using WebDAV"); + testFolder1 = FolderModel.getRandomFolderModel(); + webDavProtocol.usingResource(parentFolder).createFolder(testFolder1) + .assertThat().existsInWebdav() + .and().assertThat().existsInRepo(); + + STEP("6. Delete parentFolder using WebDAV 7. Verify folder is deleted along with all its children"); + webDavProtocol.usingResource(parentFolder).delete().and().assertThat().doesNotExistInRepo() + .usingResource(testFolder1).assertThat().doesNotExistInRepo() + .usingResource(testFile1).assertThat().doesNotExistInRepo() + .usingResource(testFile2).assertThat().doesNotExistInRepo() + .usingResource(testFile3).assertThat().doesNotExistInRepo() + .usingResource(testFile4).assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 25 + * 1. Using CMIS create 2 test users: u1 and u2 + * 2. U1 creates a public test site and adds u2 as manager to his site using CMIS + * 3. U1 creates a folder (parentFolder) inside public site's document library using CMIS + * 4. U1 creates a subfolder1 and a file1 inside parentFolder using FTP + * 5. U1 creates a subfolder2 and a file2 inside subfolder1 using CMIS + * 6. U2 creates a subfolder3 and a file3 using WebDAV + * 7. U2 deletes parentFolder using FTP + * 8. Verify folder is deleted along with all its children + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user is able to delete parent folder along with all its children using FTP.") + public void deleteFolderWithChildrenUsingFTP() throws Exception + { + STEP("1. Using CMIS create 2 test users: u1 and u2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. U1 creates a public test site using CMIS and adds u2 as manager to his site using REST"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + dataUser.usingUser(testUser1).addUserToSite(testUser2, testSitePublic, UserRole.SiteManager); + testUser2.setUserRole(UserRole.SiteManager); + + STEP("3. U1 creates a folder (parentFolder) inside public site's document library using CMIS"); + FolderModel parentFolder = FolderModel.getRandomFolderModel(); + cmisAPI.authenticateUser(testUser1) + .usingSite(testSitePublic).createFolder(parentFolder) + .assertThat().existsInRepo(); + + STEP("4. U1 creates a subfolder1 and a file1 inside parentFolder using FTP"); + FolderModel subFolder1 = FolderModel.getRandomFolderModel(); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + ftpProtocol.authenticateUser(testUser1) + .usingResource(parentFolder).createFolder(subFolder1) + .assertThat().existsInRepo() + .assertThat().existsInFtp() + .usingResource(parentFolder).createFile(testFile1) + .assertThat().existsInRepo() + .assertThat().existsInFtp(); + + STEP("5. U1 creates a subfolder2 and a file2 inside subfolder1 using CMIS"); + FolderModel subFolder2 = FolderModel.getRandomFolderModel(); + FileModel testFile2 = FileModel.getRandomFileModel(FileType.MSWORD); + + cmisAPI.authenticateUser(testUser1).usingResource(subFolder1) + .createFolder(subFolder2) + .assertThat().existsInRepo() + .createFile(testFile2) + .assertThat().existsInRepo(); + + STEP("6. U2 creates a subfolder3 and a file3 using WebDAV"); + FolderModel subFolder3 = FolderModel.getRandomFolderModel(); + FileModel testFile3 = FileModel.getRandomFileModel(FileType.HTML); + + webDavProtocol.authenticateUser(testUser2).usingResource(subFolder2) + .createFolder(subFolder3) + .assertThat().existsInWebdav() + .assertThat().existsInRepo() + .createFile(testFile3) + .assertThat().existsInWebdav() + .assertThat().existsInRepo(); + + STEP("7. U2 deletes parentFolder using FTP"); + ftpProtocol.authenticateUser(testUser2) + .usingResource(parentFolder).assertThat().existsInFtp() + .then().delete() + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp() + .usingResource(subFolder1) + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp() + .usingResource(subFolder2) + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp() + .usingResource(subFolder3) + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp() + .usingResource(testFile1) + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp() + .usingResource(testFile2) + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp() + .usingResource(testFile3) + .assertThat().doesNotExistInRepo().and() + .assertThat().doesNotExistInFtp(); + } + + /** + * Scenario 28 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a public test site + * 3. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder + * 4. Using CMIS, U1 checks out a document from parent folder + * 5. Using CMIS, U1 deletes parent folder (deleteTree) + * 6. Using WebDAV, U1 verifies that parent folder and all children are NOT present in Repo and WebDAV + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using CMIS.") + public void deleteParentFolderWithCheckoutFileInUsingCMIS() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a public test site"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("3. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder"); + FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); + FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); + FileModel ftpTestFile = FileModel.getRandomFileModel(FileType.MSWORD, "file 4 content"); + + testFolder1 = FolderModel.getRandomFolderModel(); + cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo(); + cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile) + .assertThat().existsInRepo(); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(ftpTestFile) + .assertThat().existsInFtp().assertThat().existsInRepo(); + + FolderModel cmisTestFolder = FolderModel.getRandomFolderModel(); + FolderModel webdavTestFolder = FolderModel.getRandomFolderModel(); + FolderModel ftpTestFolder = FolderModel.getRandomFolderModel(); + + cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder) + .assertThat().existsInRepo(); + webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + ftpProtocol.usingResource(testFolder1).createFolder(ftpTestFolder) + .assertThat().existsInFtp().assertThat().existsInRepo(); + + cmisAPI.usingResource(testFolder1).assertThat() + .hasChildren(cmisTestFile, webdavTestFile, ftpTestFile, cmisTestFolder, webdavTestFolder, ftpTestFolder); + + STEP("Step 4: Using CMIS, U1 checks out a document from parent folder"); + cmisAPI.usingResource(webdavTestFile).checkOut().assertThat().documentIsCheckedOut(); + + STEP("Step 5: Using CMIS, U1 deletes parent folder (deleteTree)"); + + cmisAPI.usingResource(testFolder1).deleteFolderTree() + .assertThat().doesNotExistInRepo(); + STEP("Step 6. Using WebDAV, U1 verifies that parent folder and all children are not present"); + webDavProtocol.usingResource(testFolder1).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() + .and().usingResource(cmisTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() + .and().usingResource(webdavTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() + .and().usingResource(ftpTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() + .and().usingResource(cmisTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() + .and().usingResource(webdavTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav() + .and().usingResource(ftpTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInWebdav(); + } + + /** + * Scenario 29 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a public test site + * 3. Using FTP U1 creates a parent folder in public site's document library + * 4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder + * 5. Using CMIS, U1 checks out a document from parent folder + * 6. Using WebDAV, U1 deletes parent folder (deleteFolder) + * 7. Using FTP, U1 verifies that parent folder and all children are NOT present in Repo and FTP + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using WebDAV.") + public void deleteParentFolderWithCheckoutFileInUsingWebDAV() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a public test site"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("3. Using FTP U1 creates a parent folder"); + testFolder1 = FolderModel.getRandomFolderModel(); + ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo(); + + STEP("4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder"); + FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); + FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); + FileModel ftpTestFile = FileModel.getRandomFileModel(FileType.MSWORD, "file 4 content"); + + cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile) + .assertThat().existsInRepo(); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + ftpProtocol.usingResource(testFolder1).createFile(ftpTestFile) + .assertThat().existsInFtp().assertThat().existsInRepo(); + + FolderModel cmisTestFolder = FolderModel.getRandomFolderModel(); + FolderModel webdavTestFolder = FolderModel.getRandomFolderModel(); + + cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder) + .assertThat().existsInRepo(); + webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder).assertThat().existsInWebdav() + .and().assertThat().existsInRepo(); + + cmisAPI.usingResource(testFolder1).assertThat().hasChildren(cmisTestFile, webdavTestFile, ftpTestFile, cmisTestFolder, webdavTestFolder); + + STEP("Step 5: Using CMIS, U1 checks out a document from parent folder"); + cmisAPI.usingResource(cmisTestFile).checkOut().assertThat().documentIsCheckedOut(); + + STEP("Step 6: Using WebDAV, U1 deletes parent folder (deleteFolder)"); + webDavProtocol.usingResource(testFolder1).assertThat().existsInRepo().and().assertThat().existsInWebdav() + .and().assertThat().hasFiles(cmisTestFile, webdavTestFile, ftpTestFile) + .and().assertThat().hasFolders(cmisTestFolder, webdavTestFolder) + .then().usingResource(testFolder1).delete() + .assertThat().doesNotExistInWebdav().assertThat().doesNotExistInRepo(); + + STEP("Step 7. Using FTP, U1 verifies that parent folder and all children are not present"); + ftpProtocol.usingResource(testFolder1).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() + .and().usingResource(cmisTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() + .and().usingResource(webdavTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() + .and().usingResource(ftpTestFile).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() + .and().usingResource(cmisTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp() + .and().usingResource(webdavTestFolder).assertThat().doesNotExistInRepo().assertThat().doesNotExistInFtp(); + } + + /** + * Scenario 30 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a public test site + * 3. Using WebDAV U1 creates a parent folder in public site's document library + * 4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder + * 5. Using CMIS, U1 checks out a document from parent folder + * 6. Using FTP, U1 deletes parent folder (deleteDirectory) + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE}) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION, description = "Verify deletion of a parentFolder with checkedout file using FTP.") + public void deleteParentFolderWithCheckoutFileInUsingFTP() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a public test site"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("3. Using WebDAV U1 creates a parent folder"); + testFolder1 = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1).assertThat().existsInRepo().assertThat() + .existsInWebdav(); + + STEP("4. Using CMIS, WebDAV and FTP U1 creates multiple files and folders in parent folder"); + FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); + FileModel webdavTestFile = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); + + cmisAPI.authenticateUser(testUser1).usingResource(testFolder1).createFile(cmisTestFile) + .assertThat().existsInRepo(); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(webdavTestFile) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + + FolderModel cmisTestFolder = FolderModel.getRandomFolderModel(); + FolderModel webdavTestFolder = FolderModel.getRandomFolderModel(); + FolderModel ftpTestFolder = FolderModel.getRandomFolderModel(); + + cmisAPI.usingResource(testFolder1).createFolder(cmisTestFolder) + .assertThat().existsInRepo(); + webDavProtocol.usingResource(testFolder1).createFolder(webdavTestFolder) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFolder(ftpTestFolder) + .assertThat().existsInFtp().assertThat().existsInRepo(); + + cmisAPI.usingResource(testFolder1).assertThat() + .hasChildren(cmisTestFile, webdavTestFile, cmisTestFolder, webdavTestFolder, ftpTestFolder); + + STEP("Step 5: Using CMIS, U1 checks out a document from parent folder"); + cmisAPI.usingResource(webdavTestFile).checkOut().assertThat().documentIsCheckedOut(); + + STEP("Step 6: Using FTP, U1 deletes parent folder (deleteDirectory)"); + ftpProtocol.usingResource(testFolder1).delete() + .and().assertThat().doesNotExistInFtp().and().assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 32 - Document updates + * + * 1. Using CMIS create 2 test users: U1 and U2 + * 2. Using CMIS and RestAPI U1 creates a public test site and U2 user is added with collaborator role + * 3. Using WebDAV U1 creates a folder in his public site's document library + * 4. Using WebDAV U1 creates a document inside the above folder + * 5. Using RestAPI U2 adds the document to favorites + * 6. Using CMIS U1 adds content to document + * 7. Using WebDAV U2 validates document's content + * 8. Using WebDAV U2 updates content from document + * 9. Using CMIS U2 validates document's content + * 10. Using WebDAV U1 deletes the file + * 11. Using RestAPI U1 deletes the folder + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user with collaborator role can update document content in a public site.") + public void usersCanUpdateDocumentContentInsideAPublicSite() throws Exception + { + String originalContent = "originalContent"; + String updatedContent = "updatedContent"; + testFolder1 = FolderModel.getRandomFolderModel(); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + STEP("1. Using CMIS create 2 test users: U1 and U2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS and RestAPI U1 creates a public test site and U2 user is added with collaborator role"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + testUser2.setUserRole(UserRole.SiteCollaborator); + restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2); + + STEP("3. Using WebDAV U1 creates a folder in his public site's document library"); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(testFolder1) + .and().assertThat().existsInRepo(); + + STEP("4. Using WebDAV U1 creates a document inside the above folder"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1) + .and().assertThat().existsInWebdav() + .and().assertThat().existsInRepo(); + + STEP("5. Using RestAPI U2 adds the document to favorites"); + restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFolderToFavorites(testFolder1); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + STEP("6. Using CMIS U1 adds content to document"); + cmisAPI.authenticateUser(testUser1).usingResource(testFile1) + .and().assertThat().existsInRepo() + .and().update(originalContent); + + STEP("7. Using WebDAV U2 validates document's content"); + webDavProtocol.authenticateUser(testUser2).usingResource(testFile1).assertThat().contentIs(originalContent); + + STEP("8. Using WebDAV U2 updates content from document"); + webDavProtocol.usingUser(testUser2).usingResource(testFile1) + .assertThat().existsInRepo() + .and().update(updatedContent); + + STEP("9. Using CMIS U2 validates document's content"); + cmisAPI.authenticateUser(testUser2).usingResource(testFile1).assertThat().contentIs(updatedContent); + + STEP("10. Using WebDAV U1 deletes the file"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete() + .and().assertThat().doesNotExistInRepo(); + + STEP("11. Using WebDAV U1 deletes the folder"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).delete() + .and().assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 33 - Document likes + * + * 1. Using CMIS create 2 test users: U1 and U2 + * 2. Using RestAPI U1 creates a public test site and U2 user is added with contributor role + * 3. Using WebDAV U1 creates a folder in his public site's document library + * 4. Using WebDAV U1 creates a document1 inside the above folder + * 5. Using WebDAV U2 creates a document2 inside folder + * 6. Using RestAPI U2 likes document1 + * 7. Using RestAPI U1 likes document2 + * 8. Using RestAPI U1 dislikes document2 + * 9. Using RestAPI U2 add to favorites document1 + * 10. Using CMIS U1 delete document1 + * 11. Using CMIS U2 delete the folder + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = {CmisPermissionDeniedException.class, CmisUnauthorizedException.class} ) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user with contributor role can like/favorite a document in a public site.") + public void usersCanLikeADocumentInPublicSite() throws Exception + { + STEP("1. Using CMIS create 2 test users: U1 and U2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. Using RestAPI U1 creates a public test site and U2 user is added with contributor role"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + testUser2.setUserRole(UserRole.SiteContributor); + restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2); + + STEP("3. Using WebDAV U1 creates a folder in his public site's document library"); + testFolder1 = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) + .createFolder(testFolder1).assertThat().existsInWebdav() + .and().assertThat().existsInRepo(); + + STEP("4. Using WebDAV U1 creates a document1 inside the above folder"); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + webDavProtocol.usingResource(testFolder1).createFile(testFile1) + .assertThat().existsInRepo() + .and().assertThat().existsInWebdav(); + + STEP("5. Using WebDAV U2 creates a document2 inside folder"); + testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + webDavProtocol.authenticateUser(testUser2) + .usingResource(testFolder1).createFile(testFile2).assertThat().existsInRepo() + .and().assertThat().existsInWebdav(); + + STEP("6. Using RestAPI U2 likes document1"); + RestRatingModel returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1).likeDocument(); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + STEP("7. Using RestAPI U1 likes document2"); + returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile2).likeDocument(); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true") + .and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + STEP("8. Using RestAPI U1 dislikes document2"); + restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile2).deleteLikeRating(); + restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + STEP("9. Using RestAPI U2 add to favorites document1"); + RestPersonFavoritesModel restPersonFavoritesModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingAuthUser().addFileToFavorites(testFile1); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + restPersonFavoritesModel.assertThat().field("targetGuid").is(testFile1.getNodeRefWithoutVersion()); + + STEP("10. Using CMIS U1 delete document1"); + cmisAPI.authenticateUser(testUser1).usingResource(testFile1).delete() + .and().assertThat().doesNotExistInRepo(); + + restAPI.withCoreAPI().usingResource(testFile1).getLikeRating(); + restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef())); + + RestPersonFavoritesModelsCollection userFavorites = restAPI.withCoreAPI().usingAuthUser().getFavorites(); + restAPI.assertStatusCodeIs(HttpStatus.OK); + userFavorites.assertThat().entriesListIsEmpty().and().paginationField("totalItems").is("0"); + + STEP("11. Using CMIS U2 delete the folder. With Contributor role, U2 does not have permission to delete files/folders created by others."); + cmisAPI.authenticateUser(testUser2).usingResource(testFolder1).assertThat().doesNotHaveFile(testFile1) + .and().assertThat().hasFiles(testFile2) + .and().usingResource(testFile2).delete() + .and().usingResource(testFolder1).delete(); + } + + /** + * Scenario 34 - Document ratings + * + * 1. Using CMIS create 2 test users: U1 and U2 + * 2. Using RestAPI U1 creates a public test site and U2 user is added with collaborator role + * 3. Using CMIS U1 creates a new folder in site + * 4. Using WebDAV U2 creates file1 in public site document library + * 5. Using WebDAV U1 creates a file2 in public site document library + * 6. Using RestAPI U2 rates with 5 stars file2 + * 7. Using RestAPI U1 rates with 1 star file1 + * 8. Using RestAPI U2 likes file1 + * 9. Using RestAPI U2 removes the rating of 5 stars for file2 + * 10. Using WebDAV U1 delete file1. Using RestAPI get ratings of file1. + * 11. Using WebDAV U1 delete the folder + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify user with collaborator role can rate a document in a public site.") + public void usersCanRateADocumentInPublicSite() throws Exception + { + RestRatingModel returnedRatingModel; + + STEP("1. Using CMIS create 2 test users: U1 and U2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. Using RestAPI U1 creates a public test site and U2 user is added with collaborator role"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + testUser2.setUserRole(UserRole.SiteCollaborator); + restAPI.authenticateUser(testUser1).withCoreAPI().usingSite(testSitePublic).addPerson(testUser2); + + STEP("3. Using CMIS U1 creates a new folder in site"); + testFolder1 = FolderModel.getRandomFolderModel(); + cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic) + .createFolder(testFolder1).assertThat().existsInRepo(); + + STEP("4. Using WebDAV U2 creates file1 in public site document library"); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + webDavProtocol.authenticateUser(testUser2).usingResource(testFolder1) + .createFile(testFile1).assertThat().existsInRepo() + .and().assertThat().existsInWebdav(); + + STEP("5. Using WebDAV U1 creates a file2 in public site document library"); + testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) + .usingResource(testFolder1).createFile(testFile2).assertThat().existsInRepo(); + + STEP("6. Using RestAPI U2 rates with 5 stars file2"); + returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile2) + .rateStarsToDocument(5); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + STEP("7. Using RestAPI U1 rates with 1 star file1"); + returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(testFile1) + .rateStarsToDocument(1); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("1").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + STEP("8. Using RestAPI U2 likes file1"); + returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile1) + .likeDocument(); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + STEP("9. Using RestAPI U2 removes the rating of 5 stars for file2"); + restAPI.authenticateUser(testUser2).withCoreAPI().usingResource(testFile2).deleteFiveStarRating(); + restAPI.assertStatusCodeIs(HttpStatus.NO_CONTENT); + + returnedRatingModel = restAPI.withCoreAPI().usingResource(testFile2).getFiveStarRating(); + restAPI.assertStatusCodeIs(HttpStatus.OK); + returnedRatingModel.getAggregate().assertThat().field("numberOfRatings").is("0"); + + STEP("10. Using WebDAV U1 delete file1. Using RestAPI get ratings of file1."); + webDavProtocol.authenticateUser(testUser1).usingResource(testFile1).delete() + .and().assertThat().doesNotExistInRepo() + .and().assertThat().doesNotExistInWebdav(); + + restAPI.withCoreAPI().usingResource(testFile1).getLikeRating(); + restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef())); + + restAPI.withCoreAPI().usingResource(testFile1).getFiveStarRating(); + restAPI.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, testFile1.getNodeRef())); + + STEP("11. Using WebDAV U1 delete the folder"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).assertThat().hasFiles(testFile2) + .and().usingResource(testFolder1).delete() + .and().assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 35 + * 1. Using CMIS create 2 test user: U1 and U2 + * 2. Using CMIS U1 creates a public test site + * 3. Using FTP U1 creates a folder in public site's document library: folder1 + * 4. Using WebDAV U1 creates inside folder1 a new folder: folder2 + * 5. Using WebDAV U1 creates inside folder2 a new folder: folder3 + * 6. Using CMIS U1 creates inside folder1 a new file: file1 + * 7. Using WebDAV U1 creates inside folder2 a new file: file2 + * 8. Using FTP U1 creates inside folder3 a new file: file3 + * 9. Using WebDAV U1 deletes file1 + * 10. Using IMAP U1 deletes file2 + * 11. Using WebDAV U1 updates content of file3 + * 12. Using RestAPI U1 adds a comment to file3 + * 13. Using RestAPI U1 likes file3 and user U2 rates file3 + * 14. Using CMIS U1 deletes file3 + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "File handling - perform actions: create, delete, add comment, like and rate, update file content ") + public void fileHandlingCreateUpdateContentDeleteLikeAndRate() throws Exception + { + STEP("1. Using CMIS create 1 test user: U1 and U2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. U1 creates a public test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); + + STEP("3. Using FTP U1 creates folder: folder1"); + FolderModel folder1 = FolderModel.getRandomFolderModel(); + ftpProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder1) + .assertThat().existsInRepo(); + + STEP("4. Using WebDAV U1 creates folder2 inside folder1"); + FolderModel folder2 = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1).usingResource(folder1).createFolder(folder2); + + STEP("5. Using webDAV U1 creates folder3 inside folder2"); + FolderModel folder3 = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1).usingResource(folder2).createFolder(folder3); + + STEP("6. Using CMIS U1 creates file1 inside folder1"); + FileModel file1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); + cmisAPI.authenticateUser(testUser1).usingResource(folder1).createFile(file1) + .assertThat().existsInRepo(); + + STEP("7. Using webDAV U1 creates file2 inside folder2"); + FileModel file2 = FileModel.getRandomFileModel(FileType.HTML, "file 2 content"); + webDavProtocol.authenticateUser(testUser1).usingResource(folder2).createFile(file2) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + + STEP("8. Using FTP U1 creates file3 inside folder3"); + FileModel file3 = FileModel.getRandomFileModel(FileType.MSWORD, "file 3 content"); + ftpProtocol.authenticateUser(testUser1).usingResource(folder3).createFile(file3) + .assertThat().existsInRepo(); + + STEP("9. Using webDAV U1 deletes file1"); + webDavProtocol.authenticateUser(testUser1).usingResource(file1).delete() + .assertThat().doesNotExistInRepo().and().assertThat().doesNotExistInWebdav(); + + STEP("10. Using IMAP U1 deletes file2"); + imapProtocol.authenticateUser(testUser1).usingResource(file2).deleteMessage() + .and().usingResource(file2).assertThat().doesNotExistInRepo(); + + STEP("11. Using WebDAV U1 update content of file3"); + webDavProtocol.authenticateUser(testUser1) + .usingResource(file3).assertThat().existsInRepo() + .update(newContent).assertThat().contentIs(newContent); + + STEP("12. Using RestAPI U1 adds a comment to file3"); + String comment = RandomData.getRandomName("comment1"); + file3.setNodeRef(dataContent.usingUser(testUser1).usingSite(testSitePublic) + .usingResource(folder3).usingResource(file3).getNodeRef()); + RestCommentModel commentModel = restAPI.authenticateUser(testUser1).withCoreAPI() + .usingResource(file3).addComment(comment); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + commentModel.assertThat().field("content").isNotEmpty() + .and().field("content").is(comment); + + STEP("13. Using RestAPI U1 likes file3 and user U2 rates file3"); + returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI().usingResource(file3).likeDocument(); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes").and().field("aggregate").isNotEmpty(); + + returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI() + .usingResource(file3).rateStarsToDocument(5); + restAPI.assertStatusCodeIs(HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar").and().field("aggregate").isNotEmpty(); + + STEP("14. Using CMIS U1 deletes file3"); + cmisAPI.authenticateUser(testUser1).usingResource(file3).delete() + .assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 37 + * 1. Using CMIS creates 2 users: U1 and U + * 2. U1 creates a public test site using CMIS + * 3. Using CMIS U1 creates folder: folder1 + * 4. Using WebDAV U1 creates folder2 and folder3 inside folder1 + * 5. Using FTP U1 creates file1 inside folder1 + * 6. Using CMIS U1 copies file1 to folder2 + * 7. Using WebDAV U1 update content of file1 from folder2 + * 8. Using FTP U1 tries to move file1 from folder2 to folder1 + * 9. Using WebDAV U1 updates content of file1 from folder1 + * 10. Using RestAPI U1 adds file1 to favorites + * 11. Using RestAPI U1 likes file1 and U2 user rates file1 + * 12. Using CMIS U1 moves file1 from folder1 to folder3 + * 13. Using CMIS/RestAPI U1 checks that content, favorites and ratings are kept + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "File handling - perform actions: copy, move, add/update content, favorites, like and rate") + public void fileHandlingCopyMoveAddUpdateContentFavoritesLikeAndRate() throws Exception + { + STEP("1. Using CMIS creates 2 users: U1 and U2"); + testUser1 = dataUser.createRandomTestUser(); + testUser2 = dataUser.createRandomTestUser(); + + STEP("2. U1 creates a public test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("3. Using CMIS U1 creates folder: folder1"); + FolderModel folder1 = FolderModel.getRandomFolderModel(); + cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder1) + .assertThat().existsInRepo(); + + STEP("4. Using WebDAV U1 creates folder2 and folder3 inside folder1"); + FolderModel folder2 = FolderModel.getRandomFolderModel(); + FolderModel folder3 = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1) + .usingResource(folder1).createFolder(folder2).and().assertThat().existsInWebdav() + .usingResource(folder1).createFolder(folder3).and().assertThat().existsInWebdav(); + + STEP("5. Using FTP U1 creates file1 inside folder1"); + FileModel file1 = FileModel.getRandomFileModel(FileType.MSWORD2007, "tasTesting"); + ftpProtocol.authenticateUser(testUser1).usingResource(folder1).createFile(file1) + .assertThat().existsInRepo(); + + STEP("6. Using CMIS U1 copies file1 to folder2"); + FileModel copiedFile = new FileModel(file1); + cmisAPI.authenticateUser(testUser1).usingResource(file1).copyTo(folder2); + copiedFile.setCmisLocation(cmisAPI.getLastResource()); + cmisAPI.usingResource(folder2).assertThat().hasFiles(file1); + + STEP("7. Using WebDAV U1 update content of file1 from folder2"); + webDavProtocol.usingResource(copiedFile).assertThat().existsInRepo() + .update(newContent).assertThat().contentIs(newContent); + + STEP("8. Using FTP U1 tries to move file1 from folder2 to folder1"); + ftpProtocol.authenticateUser(testUser1) + .usingResource(copiedFile).moveTo(folder1).assertThat().existsInRepo(); + Assert.assertTrue(ftpProtocol.usingResource(folder1).getFiles().size() == 1); + + STEP("9. Using WebDAV U1 updates content of file1 from folder1"); + webDavProtocol.usingResource(file1).update("content folder1") + .assertThat().contentIs("content folder1"); + + STEP("10. Using RestAPI U1 adds file1 to favorites"); + file1.setNodeRef(dataContent.usingUser(testUser1).usingSite(testSitePublic) + .usingResource(folder1).usingResource(file1).getNodeRef()); + + restPersonFavoritesModel = restAPI.authenticateUser(testUser1).withCoreAPI() + .usingAuthUser().addFileToFavorites(file1); + restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED); + restPersonFavoritesModel.assertThat().field("targetGuid").is(file1.getNodeRefWithoutVersion()); + + STEP("11. Using RestAPI U1 likes file1 and U2 user rates file1"); + returnedRatingModel = restAPI.authenticateUser(testUser1).withCoreAPI() + .usingResource(file1).likeDocument(); + restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("true").and().field("id").is("likes") + .and().field("aggregate").isNotEmpty(); + + returnedRatingModel = restAPI.authenticateUser(testUser2).withCoreAPI() + .usingResource(file1).rateStarsToDocument(5); + restAPI.assertStatusCodeIs(org.springframework.http.HttpStatus.CREATED); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + + STEP("12. Using CMIS U1 moves file1 from folder1 to folder3"); + cmisAPI.usingSite(testSitePublic).usingResource(file1).moveTo(folder3) + .and().assertThat().existsInRepo(); + + STEP("13. Using CMIS/RestAPI U1 checks that content, favorites and ratings are kept"); + returnedRatingModel.assertThat().field("myRating").is("5").and().field("id").is("fiveStar") + .and().field("aggregate").isNotEmpty(); + restPersonFavoritesModel.assertThat().field("targetGuid").is(file1.getNodeRefWithoutVersion()); + } + + /** + * Scenario 38 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a new document in Share + * 3. Using WebDAV U1 creates a new document in User Home + * 4. Using WebDAV U1 updates both documents + * 5. Verify if only first document's version is increased using CMIS + * 6. Verify if content is updated using WebDav + * 7. Verify if the size of the document is increased + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify document versioning after appending content using WebDAV.") + public void checkDocumentVersionAfterAppendingContent() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a new document in Share"); + FileModel cmisTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 1 content"); + cmisAPI.authenticateUser(testUser1) + .usingShared().createFile(cmisTestFile) + .assertThat().existsInRepo(); + + STEP("3. Using WebDAV U1 creates a new document in User Home"); + FileModel webDAVTestFile = FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file 2 content"); + webDavProtocol.authenticateUser(testUser1) + .usingUserHome().createFile(webDAVTestFile) + .assertThat().existsInWebdav().and() + .assertThat().existsInRepo(); + + STEP("4. Using WebDAV U1 updates both documents"); + webDavProtocol.usingResource(cmisTestFile).update("cmis file content") + .usingResource(webDAVTestFile).update("WebDAV file content"); + + STEP("5. Verify if only first document's version is increased using CMIS"); + cmisAPI.usingResource(cmisTestFile).assertThat().documentHasVersion(1.1) + .usingResource(webDAVTestFile).assertThat().documentHasVersion(1.0); + + STEP("6. Verify if content is updated using WebDav"); + webDavProtocol.authenticateUser(testUser1) + .usingResource(cmisTestFile).assertThat().contentIs("cmis file content") + .usingResource(webDAVTestFile).assertThat().contentIs("WebDAV file content"); + + STEP("7. Verify if the size of the document is increased"); + cmisAPI.usingResource(cmisTestFile).assertThat().contentLengthIs(17) + .usingResource(webDAVTestFile).assertThat().contentLengthIs(19); + } + + /** + * Scenario 40 + * 1. Using CMIS create test user: U1 + * 2. U1 creates a private test site using CMIS + * 3. Using WebDAV U1 creates a folder + * 4. Using WebDAV U1 creates a file inside the folder + * 5. Using CMIS, check out the document + * 6. Using CMIS verify if PWC is created + * 7. Using CMIS check in document with content + * 8. Using CMIS verify that version does not increase + * 9. Using CMIS verify new content is added to document + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify increased version and new content of a file that was check out then check in.") + public void verifyIncreasedVersionAndNewContentOfCheckInDocument() throws Exception + { + STEP("Step 1. Using CMIS create test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("Step 2. U1 creates a private test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createPrivateRandomSite(); + + STEP("Step 3. Using WebDAV U1 creates a folder"); + FolderModel folder = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder); + + STEP("Step 4. Using WebDAV U1 creates a file inside the folder"); + FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content"); + webDavProtocol.authenticateUser(testUser1).usingResource(folder).createFile(file) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + + STEP("Step 5: Using CMIS, check out the document and verify document version"); + cmisAPI.authenticateUser(testUser1).usingResource(file).checkOut() + .assertThat().documentIsCheckedOut(); + + STEP("Step 6: Using CMIS verify if PWC is created"); + FileModel filePWC = cmisAPI.usingResource(file).withCMISUtil().getPWCFileModel(); + cmisAPI.usingResource(filePWC).assertThat().existsInRepo(); + + STEP("Step 7: Using CMIS check in document with content"); + String newContent = "new major content"; + cmisAPI.usingResource(folder).assertThat().folderHasCheckedOutDocument(file); + cmisAPI.usingResource(file).prepareDocumentForCheckIn() + .withMajorVersion() + .withContent(newContent) + .checkIn().refreshResource() + .and().assertThat().documentIsNotCheckedOut(); + + STEP("Step 8: Using CMIS verify that version does not increase"); + cmisAPI.usingResource(file).assertThat().documentHasVersion(1.0); + + STEP("Step 9: Using CMIS verify new content is added to document"); + cmisAPI.usingResource(file).assertThat().contentIs(newContent); + } + + /** + * Scenario 41 + * 1. Using CMIS create test user: U1 + * 2. U1 creates a private test site using CMIS + * 3. Using WebDAV U1 creates a folder + * 4. Using WebDAV U1 creates a file inside the folder + * 5. Using CMIS, check out the document + * 6. Using CMIS verify if PWC is created + * 7. Using CMIS, cancel check out + * 8. Using CMIS, verify original document has version 1.0 + * 9. Using CMIS, verify original document has same content + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Verify that version and the content of a file are not changed if the checkout is canceled.") + public void verifyVersionAndContentOfACanceledCheckoutDocument() throws Exception + { + STEP("Step 1. Using CMIS create test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("Step 2. U1 creates a private test site using CMIS"); + testSitePublic = dataSite.usingUser(testUser1).createPrivateRandomSite(); + + STEP("Step 3. Using WebDAV U1 creates a folder"); + FolderModel folder = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(folder); + + STEP("Step 4. Using WebDAV U1 creates a file inside the folder"); + FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content"); + webDavProtocol.authenticateUser(testUser1).usingResource(folder).createFile(file) + .assertThat().existsInWebdav().assertThat().existsInRepo(); + + STEP("Step 5: Using CMIS, check out the document"); + cmisAPI.authenticateUser(testUser1).usingResource(file).checkOut(); + + STEP("Step 6: Using CMIS verify if PWC is created"); + FileModel filePWC = cmisAPI.usingResource(file).withCMISUtil().getPWCFileModel(); + cmisAPI.usingResource(filePWC).assertThat().existsInRepo(); + + STEP("Step 7: Using CMIS, cancel check out"); + cmisAPI.usingResource(file).cancelCheckOut().then() + .assertThat().documentIsNotCheckedOut(); + + STEP("Step 8: Using CMIS, verify original document has version 1.0"); + cmisAPI.usingResource(file).assertThat().isNotPrivateWorkingCopy() + .then().assertThat().documentHasVersion(1.0); + + STEP("Step 9: Using CMIS, verify original document has same content"); + cmisAPI.usingResource(file).assertThat().contentIs("file content"); + } + + /** + * Scenario 42 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a file: file + * 3. Using WebDAV U1 renames file and verify if the new document exists + * 4. Using FTP verify old document does not exists + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Edit document name and verify document with new name") + public void renameDocument() throws Exception + { + STEP("1. Using CMIS create test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates file"); + FileModel file = FileModel.getRandomFileModel(FileType.PDF, "file content"); + cmisAPI.authenticateUser(testUser1).usingUserHome().createFile(file) + .assertThat().existsInRepo(); + + STEP("3. Using WebDAV U1 renames file and verify if the new document exists"); + FileModel oldFile = new FileModel(file); + webDavProtocol.authenticateUser(testUser1).usingResource(file).rename(renamePrefix + file.getName()) + .and().assertThat().existsInRepo().and().assertThat().existsInWebdav(); + + STEP("4. Using FTP verify old document does not exists"); + ftpProtocol.authenticateUser(testUser1).usingResource(oldFile) + .assertThat().doesNotExistInRepo() + .and().assertThat().doesNotExistInFtp(); + } + + /** + * Scenario 43 + * 1. Using CMIS create test user: U1 + * 2. Using WebDAV U1 creates a file using shared + * 3. Using webDAV append content to document + * 4. Using CMIS, verify original document has version 1.0 + * 5. Using CMIS delete document + * 6. Using WebDAV, verify document is deleted + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, + description = "Delete document after append content and verify document version.") + public void deleteDocumentAfterAppendContent() throws Exception + { + STEP("Step 1. Using CMIS create test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("Step 2. Using WebDAV U1 creates a file using shared"); + FileModel file = FileModel.getRandomFileModel(FileType.XML, "file content"); + webDavProtocol.authenticateUser(testUser1).usingUserHome().createFile(file) + .assertThat().existsInRepo(); + + STEP("Step 3. Using webDAV append content to document"); + String newContentToAppend = " - append this text to the file"; + webDavProtocol.authenticateUser(testUser1).usingResource(file).assertThat().contentIs("file content") + .then().update(file.getContent() + newContentToAppend) + .assertThat().contentIs(file.getContent() + newContentToAppend); + + STEP("Step 4: Using CMIS, verify original document has version 1.0"); + cmisAPI.authenticateUser(testUser1).usingResource(file).assertThat().isNotPrivateWorkingCopy() + .then().assertThat().documentHasVersion(1.0); + + STEP("Step 4: Using CMIS, delete document"); + cmisAPI.usingResource(file).assertThat().existsInRepo().delete(); + + STEP("Step 5: Using WebDAV, verify document is deleted"); + webDavProtocol.authenticateUser(testUser1).usingResource(file).assertThat().doesNotExistInWebdav() + .and().assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 44 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a public test site + * 3. Using WebDAV U1 creates a new file in User Home + * 4. Using WebDAV U1 creates another file in public site document library. + * 5. Using CMIS U1 creates a relationship between documents + * 6. Verify if relationship is created + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify if relationship is created between 2 items using CMIS.") + public void checkRelationshipBetween2Files() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a public test site"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("3. Using WebDAV U1 creates a new file in User Home"); + FileModel sourceFile= FileModel.getRandomFileModel(FileType.PDF, "file content"); + webDavProtocol.authenticateUser(testUser1).usingUserHome() + .createFile(sourceFile).assertThat().existsInRepo(); + + STEP("4. Using WebDAV U1 creates another file in public site document library."); + FileModel targetFile= FileModel.getRandomFileModel(FileType.PDF, "file content"); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) + .createFile(targetFile).assertThat().existsInRepo(); + + STEP("5. Using CMIS U1 creates a relationship between documents. 6. Verify if relationship is created"); + cmisAPI.authenticateUser(testUser1).usingResource(sourceFile).createRelationshipWith(targetFile) + .assertThat().objectHasRelationshipWith(targetFile); + } + + /** + * Scenario 46 + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates an imap test site + * 3. Using CMIS U1 creates cmisFolder in Shared + * 4. Using IMAP U1 creates parentFolder in private site document library. + * 5. Using FTP U1 creates a subfolder in parentFolder + * 6. Using WebDAV U1 creates a webdavFolder in User Home + * 7. Using WebDAV U1 creates a document in parentFolder + * 8. Using CMIS U1 adds document to cmisFolder, subfolder, webdavFolder + * 9. Using WebDAV verify document is present in all folders + * 10. Using CMIS U1 removes document from subFolder + * 11. Using WebDAV verify document is not present in subFolder + * 12. Using FTP U1 deletes original document from parentFolder + * 13. Using CMIS verify document does not exist + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify parents list for an object using CMIS.") + public void addAndRemoveDocumentFromFolders() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates an imap test site"); + testSitePublic = dataSite.usingUser(testUser1).createIMAPSite(); + + STEP("3. Using CMIS U1 creates cmisFolder in Shared"); + FolderModel cmisFolder = FolderModel.getRandomFolderModel(); + cmisAPI.authenticateUser(testUser1) + .usingShared().createFolder(cmisFolder) + .assertThat().existsInRepo(); + + STEP("4. Using IMAP U1 creates parentFolder in private site document library."); + FolderModel parentFolder = FolderModel.getRandomFolderModel(); + imapProtocol.authenticateUser(testUser1) + .usingSite(testSitePublic).createFolder(parentFolder) + .assertThat().existsInRepo(); + + STEP("5. Using FTP U1 creates a subfolder in parentFolder"); + FolderModel subFolder = FolderModel.getRandomFolderModel(); + ftpProtocol.authenticateUser(testUser1) + .usingResource(parentFolder).createFolder(subFolder) + .assertThat().existsInRepo(); + + STEP("6. Using WebDAV U1 creates a webdavFolder in User Home"); + FolderModel webdavFolder = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1) + .usingUserHome().createFolder(webdavFolder) + .assertThat().existsInRepo(); + + STEP("7. Using WebDAV U1 creates a document in parentFolder"); + testFile1= FileModel.getRandomFileModel(FileType.TEXT_PLAIN, "file content"); + webDavProtocol.authenticateUser(testUser1) + .usingResource(parentFolder).createFile(testFile1) + .assertThat().existsInRepo(); + + STEP("8. Using CMIS U1 adds document to cmisFolder, subfolder, webdavFolder"); + cmisAPI.usingResource(testFile1) + .addDocumentToFolder(cmisFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName()) + .addDocumentToFolder(subFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), subFolder.getName()) + .addDocumentToFolder(webdavFolder, true).assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), subFolder.getName(), webdavFolder.getName()); + + STEP("9. Using WebDAV verify document is present in all folders"); + FileModel fileAddedInCMISFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); + fileAddedInCMISFolder.setCmisLocation(Utility.buildPath(cmisFolder.getCmisLocation(), testFile1.getName())); + + FileModel fileAddedInSubFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); + fileAddedInSubFolder.setCmisLocation(Utility.buildPath(subFolder.getCmisLocation(), testFile1.getName())); + + FileModel fileAddedInWebDAVFolder = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); + fileAddedInWebDAVFolder.setCmisLocation(Utility.buildPath(webdavFolder.getCmisLocation(), testFile1.getName())); + + webDavProtocol.usingResource(fileAddedInCMISFolder).assertThat().existsInWebdav() + .usingResource(fileAddedInSubFolder).assertThat().existsInWebdav() + .usingResource(fileAddedInWebDAVFolder).assertThat().existsInWebdav(); + + STEP("10. Using CMIS U1 removes document from subFolder"); + cmisAPI.usingResource(testFile1).removeDocumentFromFolder(subFolder) + .assertThat().hasParents(parentFolder.getName(), cmisFolder.getName(), webdavFolder.getName()); + + STEP("11. Using WebDAV verify document is not present in subFolder"); + webDavProtocol.usingResource(testFile1).assertThat().existsInWebdav() + .usingResource(fileAddedInCMISFolder).assertThat().existsInWebdav() + .usingResource(fileAddedInSubFolder).assertThat().doesNotExistInWebdav() + .usingResource(fileAddedInWebDAVFolder).assertThat().existsInWebdav(); + + STEP("12. Using FTP U1 deletes original document from parentFolder"); + ftpProtocol.usingResource(testFile1).delete().assertThat().doesNotExistInFtp(); + + STEP("13. Using CMIS verify document does not exist"); + cmisAPI.usingResource(fileAddedInCMISFolder).assertThat().doesNotExistInRepo() + .usingResource(fileAddedInWebDAVFolder).assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 47 - Delete many documents + * + * 1. Using CMIS create test user: U1 + * 2. Using CMIS U1 creates a public test site + * 3. Using CMIS and WebDAV U1 creates parentFolder1, doc1 and doc2 in document library + * 4. Using WebDAV and FTP U1 creates inside parentFolder1: childDoc1 to childDoc5 + * 5. Using IMAP bulk delete doc1 and doc2 + * 6. Using CMIS verify that doc1 and doc2 are deleted + * 7. Using IMAP delete childDoc1 to childDoc4 + * 8. Using WebDAV and FTP verify if docs are deleted from their folders + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT}, executionType = ExecutionType.REGRESSION, + description = "Verify users can delete many documents in a public site using different protocols.") + public void usersCanDeleteManyDocuments() throws Exception + { + FolderModel parentFolder1 = FolderModel.getRandomFolderModel(); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + testFile2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + FileModel childDoc1, childDoc2, childDoc3, childDoc4, childDoc5; + childDoc1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + childDoc2 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + childDoc3 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + childDoc4 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + childDoc5 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + STEP("1. Using CMIS create test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a public test site"); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("3. Using CMIS and WebDAV U1 creates parentFolder1, doc1 and doc2 in document library"); + cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic).createFolder(parentFolder1) + .and().assertThat().existsInRepo(); + + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic).createFile(testFile1) + .and().createFile(testFile2); + + STEP("4. Using WebDAV and FTP U1 creates inside parentFolder1: childDoc1 to childDoc5"); + webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder1) + .createFile(childDoc1).and().createFile(childDoc2); + + ftpProtocol.authenticateUser(testUser1).usingResource(parentFolder1) + .createFile(childDoc3).and().createFile(childDoc4).and().createFile(childDoc5); + + STEP("5. Using IMAP bulk delete doc1 and doc2"); + imapProtocol.authenticateUser(testUser1).usingSite(testSitePublic).deleteMessage(testFile1.getName(), testFile2.getName()).assertThat().doesNotContainMessages(testFile1, testFile2); + + STEP("6. Using CMIS verify that doc1 and doc2 are deleted"); + Utility.sleep(500, 10000, () -> + cmisAPI.authenticateUser(testUser1) + .usingResource(testFile1).assertThat().doesNotExistInRepo() + .and().usingResource(testFile2).assertThat().doesNotExistInRepo()); + + STEP("7. Using IMAP delete childDoc1 to childDoc4"); + imapProtocol.authenticateUser(testUser1).usingResource(parentFolder1).deleteMessage(childDoc1.getName(), childDoc2.getName(), childDoc3.getName(), childDoc4.getName()) + .assertThat().doesNotContainMessages(childDoc1, childDoc2, childDoc3, childDoc4); + + STEP("8. Using WebDAV and FTP verify if docs are deleted from their folders"); + Utility.sleep(500, 10000, () -> + webDavProtocol.authenticateUser(testUser1).usingResource(parentFolder1).assertThat().hasFiles(childDoc5) + .and().usingResource(childDoc1).assertThat().doesNotExistInRepo() + .and().usingResource(childDoc2).assertThat().doesNotExistInRepo()); + + ftpProtocol.authenticateUser(testUser1).usingResource(childDoc3) + .assertThat().doesNotExistInRepo() + .and().usingResource(childDoc4).assertThat().doesNotExistInRepo(); + } + + /** + * Scenario 48 - Move folder in another folder + * + * 1. Using CMIS create user u1 and public site + * 2. Using WebDAV U1 creates folder1 and folder2 + * 3. Using WebDAV U1 creates doc1 in folder1 + * 4. Using FTP U1 moves folder1 in folder2 + * 5. Using WebDAV verify that folder1 is not in the original location and is present in folder2 + * 6. Using CMIS verify if doc1 is still present in folder1 + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to move a non empty folder to another folder from the same site.") + public void moveFolderInAnotherFolder() throws Exception + { + testFolder1 = FolderModel.getRandomFolderModel(); + testFolder2 = FolderModel.getRandomFolderModel(); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + STEP("1. Using CMIS create user u1 and public site"); + testUser1 = dataUser.createRandomTestUser(); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("2. Using WebDAV U1 creates folder1 and folder2"); + webDavProtocol.authenticateUser(testUser1).usingSite(testSitePublic) + .createFolder(testFolder1) + .and().assertThat().existsInRepo().and().assertThat().existsInWebdav() + .then().createFolder(testFolder2) + .and().assertThat().existsInRepo().and().assertThat().existsInWebdav(); + + STEP("3. Using WebDAV U1 creates doc1 in folder1"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).createFile(testFile1) + .and().assertThat().existsInRepo().and().assertThat().existsInWebdav() + .and().usingResource(testFolder1).assertThat().hasFiles(testFile1); + + STEP("4. Using FTP U1 moves folder1 in folder2"); + ftpProtocol.authenticateUser(testUser1) + .usingResource(testFolder1).moveTo(testFolder2) + .assertThat().existsInRepo() + .then().usingResource(testFolder1).assertThat().doesNotExistInRepo(); + + STEP("5. Using WebDAV verify that folder1 is not in the original location and is present in folder2"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).assertThat().doesNotExistInRepo() + .and().usingResource(testFolder2).assertThat().hasFolders(testFolder1); + + STEP("6. Using CMIS verify if doc1 is still present in folder1"); + FolderModel newTestFolder1 = new FolderModel(testFolder1.getName(), testFolder1.getTitle(), testFolder1.getDescription()); + newTestFolder1.setCmisLocation(Utility.buildPath(testFolder2.getCmisLocation(), testFolder1.getName())); + + FileModel newTestFile1 = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); + newTestFile1.setCmisLocation(Utility.buildPath(newTestFolder1.getCmisLocation(), testFile1.getName())); + + cmisAPI.authenticateUser(testUser1).usingResource(newTestFolder1) + .assertThat().existsInRepo() + .assertThat().hasFiles(newTestFile1); + } + + /** + * Scenario 49 - Copy folder in another folder + * + * 1. Using CMIS create user u1 and public site + * 2. Using CMIS U1 creates folder1 and folder2 + * 3. Using WebDAV U1 creates doc1 in folder1 + * 4. Using WebDAV U1 copies folder1 in folder2 + * 5. Using FTP verify that folder1 is in the original location and contains doc1 + * 6. Using WebDAV verify that folder1 is in folder2 and contains doc1 + */ + + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }) + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify user is able to copy non empty folder to another folder in the same site.") + public void copyFolderInAnotherFolder() throws Exception + { + testFolder1 = FolderModel.getRandomFolderModel(); + testFolder2 = FolderModel.getRandomFolderModel(); + testFile1 = FileModel.getRandomFileModel(FileType.TEXT_PLAIN); + + STEP("1. Using CMIS create user u1 and public site"); + testUser1 = dataUser.createUser(RandomStringUtils.randomAlphanumeric(20)); + testSitePublic = dataSite.usingUser(testUser1).createPublicRandomSite(); + + STEP("2. Using CMIS U1 creates folder1 and folder2"); + cmisAPI.authenticateUser(testUser1).usingSite(testSitePublic) + .createFolder(testFolder1).and().assertThat().existsInRepo().and() + .createFolder(testFolder2).and().assertThat().existsInRepo(); + + STEP("3. Using WebDAV U1 creates doc1 in folder1"); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1) + .createFile(testFile1).and().assertThat().existsInRepo() + .and().assertThat().existsInWebdav(); + + STEP("4. Using WebDAV U1 copies folder1 in folder2"); + testFolder2.setProtocolLocation(webDavProtocol.getPrefixSpace() + testFolder2.getCmisLocation()); + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder1).copyTo(testFolder2) + .assertThat().existsInRepo() + .then().usingResource(testFolder1).assertThat().existsInRepo(); + + STEP("5. Using FTP verify that folder1 is in the original location and contains doc1"); + ftpProtocol.authenticateUser(testUser1).usingResource(testFolder1) + .assertThat().existsInRepo() + .and().assertThat().existsInFtp() + .and().assertThat().hasFiles(testFile1); + + STEP("6. Using WebDAV verify that folder1 is in folder2 and contains doc1"); + FolderModel newTestFolder1 = new FolderModel(testFolder1.getName(), testFolder1.getTitle(), testFolder1.getDescription()); + newTestFolder1.setCmisLocation(Utility.buildPath(testFolder2.getCmisLocation(), testFolder1.getName())); + + FileModel newTestFile1 = new FileModel(testFile1.getName(), testFile1.getTitle(), testFile1.getDescription(), testFile1.getFileType(), testFile1.getContent()); + newTestFile1.setCmisLocation(Utility.buildPath(newTestFolder1.getCmisLocation(), testFile1.getName())); + + webDavProtocol.authenticateUser(testUser1).usingResource(testFolder2) + .assertThat().hasFolders(newTestFolder1) + .and().usingResource(newTestFolder1) + .assertThat().existsInRepo().and().assertThat().existsInWebdav() + .and().assertThat().hasFiles(newTestFile1); + } + + /** + * Scenario 50 - Rename site + * + * 1. Using CMIS create one test user: U1 + * 2. Using CMIS U1 creates a moderated site + * 3. Using WebDAV U1 creates a folder in the moderated site document library + * 4. Using CMIS U1 tries to rename site + * 5. Verify that a site cannot be renamed + */ + @Test(groups = { TestGroup.INTEGRATION, TestGroup.CORE }, expectedExceptions = CmisRuntimeException.class, expectedExceptionsMessageRegExp = "^.*Sites can not be renamed.$") + @TestRail(section = { TestGroup.INTEGRATION, TestGroup.CONTENT }, executionType = ExecutionType.REGRESSION, description = "Verify sites cannot be renamed using CMIS.") + public void renameSite() throws Exception + { + STEP("1. Using CMIS create one test user: U1"); + testUser1 = dataUser.createRandomTestUser(); + + STEP("2. Using CMIS U1 creates a moderated site"); + testSiteModerated = dataSite.usingUser(testUser1).createModeratedRandomSite(); + + STEP("3. Using WebDAV U1 creates a folder in the moderated site document library"); + testFolder1 = FolderModel.getRandomFolderModel(); + webDavProtocol.authenticateUser(testUser1) + .usingSite(testSiteModerated).createFolder(testFolder1) + .assertThat().existsInWebdav() + .assertThat().existsInRepo(); + + STEP("4. Using CMIS U1 tries to rename site 5. Verify that a site cannot be renamed"); + FolderModel siteFolder = new FolderModel(String.format("/Sites/%s", testSiteModerated.getId())); + cmisAPI.authenticateUser(testUser1).usingResource(siteFolder).rename("renamedSite"); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/nodes/NodesTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/nodes/NodesTests.java index b122296c60..d6558b1e87 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/nodes/NodesTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/nodes/NodesTests.java @@ -1,56 +1,129 @@ -package org.alfresco.rest.nodes; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; -import org.alfresco.rest.model.RestNodeModel; -import org.alfresco.rest.model.builder.NodesBuilder; -import org.alfresco.rest.model.builder.NodesBuilder.NodeDetail; -import org.alfresco.utility.model.ContentModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.Test; - -/** - * Handles tests related to api-explorer/#!/nodes - */ -public class NodesTests extends RestTest -{ - @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, - description = "Verify files can be moved from one folder to another") - @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) - public void testMoveFile() throws Exception - { - restClient.authenticateUser(dataContent.getAdminUser()); - - /* - * Create the following file structure for preconditions : - * - sourceFolder - * - file - * - destinationFolder - */ - NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); - NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); - NodeDetail file = sourceFolder.file("file"); - NodeDetail destinationFolder = nodesBuilder.folder("destinationFolder"); - - // Move file from sourceFolder to destinationFolder - RestNodeBodyMoveCopyModel moveDestinationInfo = new RestNodeBodyMoveCopyModel(); - moveDestinationInfo.setTargetParentId(destinationFolder.getId()); - - ContentModel fileToMove = new ContentModel(); - fileToMove.setNodeRef(file.getId()); - - RestNodeModel response = restClient.withParams("autoRename=true").withCoreAPI().usingNode(fileToMove).move(moveDestinationInfo); - restClient.assertStatusCodeIs(HttpStatus.OK); - - /* - * Check file's parent has changed to destinationFolder - * - sourceFolder - * - destinationFolder - * - file - */ - response.assertThat().field("parentId").is(destinationFolder.getId()); - } -} +package org.alfresco.rest.nodes; + +import static org.junit.Assert.assertEquals; + +import javax.json.Json; +import javax.json.JsonObject; + +import org.alfresco.dataprep.CMISUtil; +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.core.RestResponse; +import org.alfresco.rest.core.RestWrapper; +import org.alfresco.rest.model.RestNodeBodyMoveCopyModel; +import org.alfresco.rest.model.RestNodeModel; +import org.alfresco.rest.model.builder.NodesBuilder; +import org.alfresco.rest.model.builder.NodesBuilder.NodeDetail; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.ContentModel; +import org.alfresco.utility.model.FileModel; +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.annotations.Test; + +import io.restassured.RestAssured; + +/** + * Handles tests related to api-explorer/#!/nodes + */ +public class NodesTests extends RestTest +{ + @TestRail(section = { TestGroup.REST_API,TestGroup.NODES }, executionType = ExecutionType.SANITY, + description = "Verify files can be moved from one folder to another") + @Test(groups = { TestGroup.REST_API, TestGroup.NODES, TestGroup.SANITY}) + public void testMoveFile() throws Exception + { + restClient.authenticateUser(dataContent.getAdminUser()); + + /* + * Create the following file structure for preconditions : + * - sourceFolder + * - file + * - destinationFolder + */ + NodesBuilder nodesBuilder = restClient.withCoreAPI().usingNode(ContentModel.my()).defineNodes(); + NodeDetail sourceFolder = nodesBuilder.folder("sourceFolder"); + NodeDetail file = sourceFolder.file("file"); + NodeDetail destinationFolder = nodesBuilder.folder("destinationFolder"); + + // Move file from sourceFolder to destinationFolder + RestNodeBodyMoveCopyModel moveDestinationInfo = new RestNodeBodyMoveCopyModel(); + moveDestinationInfo.setTargetParentId(destinationFolder.getId()); + + ContentModel fileToMove = new ContentModel(); + fileToMove.setNodeRef(file.getId()); + + RestNodeModel response = restClient.withParams("autoRename=true").withCoreAPI().usingNode(fileToMove).move(moveDestinationInfo); + restClient.assertStatusCodeIs(HttpStatus.OK); + + /* + * Check file's parent has changed to destinationFolder + * - sourceFolder + * - destinationFolder + * - file + */ + response.assertThat().field("parentId").is(destinationFolder.getId()); + } + + @TestRail(section = { TestGroup.SANITY }, + executionType = ExecutionType.SANITY, + description = "Verify 403 is received for files where the user lacks permissions.") + @Test(groups = {TestGroup.SANITY}) + public void siteConsumerWillGet403OnFileWithDisabledInherittedPermissions() throws Exception + { + // https://issues.alfresco.com/jira/browse/REPO-4859 + + // Authenticate as admin to fulfill the preconditions + UserModel adminUser = dataContent.getAdminUser(); + RestWrapper restWrapper = this.restClient.authenticateUser(adminUser); + + // Create the file using CMIS + testSite = dataSite.createPublicRandomSite(); + FileModel file = dataContent + .usingUser(adminUser) + .usingSite(testSite) + .createContent(CMISUtil.DocumentType.TEXT_PLAIN); + + // Add a consumer user via CMIS + DataUser.ListUserWithRoles listUserWithRoles = dataUser.usingUser(adminUser) + .addUsersWithRolesToSite(testSite, UserRole.SiteConsumer); + + // Disable the permission inheritance + JsonObject activateModelJson = Json.createObjectBuilder().add("permissions", + Json.createObjectBuilder().add("isInheritanceEnabled", false)) + .build(); + + restWrapper.withCoreAPI().usingNode(file).updateNode(activateModelJson.toString()); + restWrapper.assertStatusCodeIs(HttpStatus.OK); + + // Authenticate as the consumer user + UserModel consumerUser = listUserWithRoles.getOneUserWithRole(UserRole.SiteConsumer); + + // Assert the consumer gets a 403 VIA REST Call + RestResponse restApiResponse = restClient.authenticateUser(consumerUser).withCoreAPI() + .usingNode(file).getNodeContent(); + + int restApiStatusCode = restApiResponse.getResponse().getStatusCode(); + logger.info("REST API call response status code is: " + restApiStatusCode); + assertEquals(HttpStatus.FORBIDDEN.value(), restApiStatusCode); + + // Assert the consumer gets a 403 VIA CMIS API + // Implement the CMIS call as it is not supported under .withCMISApi() + // This is done similar to {@link IntegrationWithCmisTests#verifyGetChildrenReturnsUniqueValues} + RestAssured.basePath = "alfresco/api/-default-/public/cmis/versions/1.1/browser"; + restWrapper.configureRequestSpec().setBasePath(RestAssured.basePath); + + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, + "/root/Sites/" + testSite.getTitle() + "/documentLibrary/" + file.getName() + "?cmisselector=object&succinct=true"); + RestResponse cmisApiResponse = restWrapper.authenticateUser(consumerUser).process(request); + + int cmisApiStatusCode = cmisApiResponse.getResponse().getStatusCode(); + logger.info("CMIS API call response status code is: " + cmisApiStatusCode); + assertEquals(HttpStatus.FORBIDDEN.value(), cmisApiStatusCode); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java index a447bd1d58..c4f5eafac2 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/people/GetPeopleFullTests.java @@ -1,88 +1,88 @@ -package org.alfresco.rest.people; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.core.RestRequest; -import org.alfresco.rest.model.RestPersonModel; -import org.alfresco.rest.model.RestPersonModelsCollection; -import org.alfresco.utility.constants.UserRole; -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.annotations.BeforeClass; -import org.testng.annotations.Test; - -public class GetPeopleFullTests extends RestTest -{ - UserModel userModel; - SiteModel siteModel; - UserModel searchedUser, managerUser; - UserModel adminUser; - private RestPersonModel personModel; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws Exception - { - adminUser = dataUser.getAdminUser(); - userModel = dataUser.createRandomTestUser(); - siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); - searchedUser = dataUser.createRandomTestUser(); - managerUser = dataUser.usingAdmin().createRandomTestUser(); - dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get person response with Rest API") - public void checkResponseSchemaForGetPerson() throws Exception - { - RestPersonModel newUser = RestPersonModel.getRandomPersonModel("aspectNames", "avatarId", "statusUpdatedAt","displayName"); - newUser = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().createPerson(newUser); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - personModel = restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel(newUser.getId(), newUser.getPassword())).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - - personModel.assertThat().field("id").is(newUser.getId()) - .and().field("firstName").is(newUser.getFirstName()) - .and().field("lastName").is(newUser.getLastName()) - .and().field("description").is(newUser.getDescription()) - .and().field("email").is(newUser.getEmail()) - .and().field("skypeId").is(newUser.getSkypeId()) - .and().field("googleId").is(newUser.getGoogleId()) - .and().field("instantMessageId").is(newUser.getInstantMessageId()) - .and().field("jobTitle").is(newUser.getJobTitle()) - .and().field("location").is(newUser.getLocation()) - .and().field("mobile").is(newUser.getMobile()) - .and().field("telephone").is(newUser.getTelephone()) - .and().field("userStatus").is(newUser.getUserStatus()) - .and().field("enabled").is(newUser.getEnabled()) - .and().field("emailNotificationsEnabled").is(newUser.getEmailNotificationsEnabled()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets a person with empty personId with Rest API and response is successful") - public void userGetPersonWithEmptyPersonId() throws Exception - { - restClient.authenticateUser(managerUser).withCoreAPI(); - RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}?{parameters}", "", restClient.getParameters()); - RestPersonModelsCollection persons = restClient.processModels(RestPersonModelsCollection.class, request); - restClient.assertStatusCodeIs(HttpStatus.OK); - persons.assertThat().entriesListIsNotEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin user with Rest API and response is successful") - public void managerUserGetAdminPerson() throws Exception - { - personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(adminUser).getPerson(); - restClient.assertStatusCodeIs(HttpStatus.OK); - personModel.assertThat().field("id").is(adminUser.getUsername()) - .and().field("firstName").is("Administrator") - .and().field("email").is("admin@alfresco.com") - .and().field("emailNotificationsEnabled").is("true") - .and().field("enabled").is("true"); - } -} +package org.alfresco.rest.people; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.core.RestRequest; +import org.alfresco.rest.model.RestPersonModel; +import org.alfresco.rest.model.RestPersonModelsCollection; +import org.alfresco.utility.constants.UserRole; +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.annotations.BeforeClass; +import org.testng.annotations.Test; + +public class GetPeopleFullTests extends RestTest +{ + UserModel userModel; + SiteModel siteModel; + UserModel searchedUser, managerUser; + UserModel adminUser; + private RestPersonModel personModel; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws Exception + { + adminUser = dataUser.getAdminUser(); + userModel = dataUser.createRandomTestUser(); + siteModel = dataSite.usingUser(userModel).createPublicRandomSite(); + searchedUser = dataUser.createRandomTestUser(); + managerUser = dataUser.usingAdmin().createRandomTestUser(); + dataUser.usingUser(userModel).addUserToSite(managerUser, siteModel, UserRole.SiteManager); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify entry details for get person response with Rest API") + public void checkResponseSchemaForGetPerson() throws Exception + { + RestPersonModel newUser = RestPersonModel.getRandomPersonModel("aspectNames", "avatarId", "statusUpdatedAt","displayName", "quota", "quotaUsed"); + newUser = restClient.authenticateUser(adminUser).withCoreAPI().usingAuthUser().createPerson(newUser); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + personModel = restClient.authenticateUser(userModel).withCoreAPI().usingUser(new UserModel(newUser.getId(), newUser.getPassword())).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + + personModel.assertThat().field("id").is(newUser.getId()) + .and().field("firstName").is(newUser.getFirstName()) + .and().field("lastName").is(newUser.getLastName()) + .and().field("description").is(newUser.getDescription()) + .and().field("email").is(newUser.getEmail()) + .and().field("skypeId").is(newUser.getSkypeId()) + .and().field("googleId").is(newUser.getGoogleId()) + .and().field("instantMessageId").is(newUser.getInstantMessageId()) + .and().field("jobTitle").is(newUser.getJobTitle()) + .and().field("location").is(newUser.getLocation()) + .and().field("mobile").is(newUser.getMobile()) + .and().field("telephone").is(newUser.getTelephone()) + .and().field("userStatus").is(newUser.getUserStatus()) + .and().field("enabled").is(newUser.getEnabled()) + .and().field("emailNotificationsEnabled").is(newUser.getEmailNotificationsEnabled()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets a person with empty personId with Rest API and response is successful") + public void userGetPersonWithEmptyPersonId() throws Exception + { + restClient.authenticateUser(managerUser).withCoreAPI(); + RestRequest request = RestRequest.simpleRequest(HttpMethod.GET, "people/{personId}?{parameters}", "", restClient.getParameters()); + RestPersonModelsCollection persons = restClient.processModels(RestPersonModelsCollection.class, request); + restClient.assertStatusCodeIs(HttpStatus.OK); + persons.assertThat().entriesListIsNotEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.PEOPLE, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.PEOPLE }, executionType = ExecutionType.REGRESSION, description = "Verify user gets admin user with Rest API and response is successful") + public void managerUserGetAdminPerson() throws Exception + { + personModel = restClient.authenticateUser(managerUser).withCoreAPI().usingUser(adminUser).getPerson(); + restClient.assertStatusCodeIs(HttpStatus.OK); + personModel.assertThat().field("id").is(adminUser.getUsername()) + .and().field("firstName").is("Administrator") + .and().field("email").is("admin@alfresco.com") + .and().field("emailNotificationsEnabled").is("true") + .and().field("enabled").is("true"); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java index 1b52694554..41ca764b0b 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMemberTests.java @@ -1,395 +1,395 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.exception.JsonToModelConversionException; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.exception.DataPreparationException; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -public class GetSiteMemberTests extends RestTest -{ - private UserModel adminUser; - private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; - private ListUserWithRoles usersWithRoles; - private UserModel manager, consumer, collaborator, contributor; - - @BeforeClass(alwaysRun = true) - public void dataPreparation() throws DataPreparationException - { - adminUser = dataUser.getAdminUser(); - publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); - moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); - privateSiteModel = dataSite.usingUser(adminUser).createPrivateRandomSite(); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, - UserRole.SiteContributor); - - consumer = dataUser.createRandomTestUser(); - manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); - collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); - contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); - - dataUser.addUserToSite(consumer, publicSiteModel, UserRole.SiteConsumer); - dataUser.addUserToSite(consumer, moderatedSiteModel, UserRole.SiteConsumer); - dataUser.addUserToSite(manager, moderatedSiteModel, UserRole.SiteManager); - dataUser.addUserToSite(consumer, privateSiteModel, UserRole.SiteConsumer); - dataUser.addUserToSite(manager, privateSiteModel, UserRole.SiteManager); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role gets site member and status code is OK (200)") - public void getSiteMemberWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) - .assertThat().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Collaborator role gets site member and gets status code OK (200)") - public void getSiteMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) - .and().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Contributor role gets site member and gets status code OK (200)") - public void getSiteMemberWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) - .and().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Consumer role gets site member and gets status code OK (200)") - public void getSiteMemberWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) - .and().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with admin user gets site member and gets status code OK (200)") - public void getSiteMemberWithAdminUser() throws Exception - { - restClient.authenticateUser(adminUser); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) - .and().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site member call returns status code 401") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception - { - UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); - restClient.authenticateUser(inexistentUser); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role doesn't get a site member of inexistent site and status code is Not Found (404)") - public void getSiteMemberOfInexistentSite() throws Exception - { - SiteModel invalidSite = new SiteModel("invalidSite"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(invalidSite).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), invalidSite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role doesn't get non site member of inexistent site and status code is Not Found (404)") - public void getSiteMemberForNonSiteMember() throws Exception - { - UserModel nonMember = dataUser.createRandomTestUser(); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(nonMember); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), publicSiteModel.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role doesn't get not existing site member and status code is Not Found (404)") - public void getSiteMemberForInexistentSiteMember() throws Exception - { - UserModel inexistentUser = new UserModel("inexistentUser", "password"); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(inexistentUser); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role can get site member using \"-me-\" in place of personId") - public void getSiteMemberUsingMeForPersonId() throws Exception - { - UserModel meUser = new UserModel("-me-", "password"); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(meUser) - .assertThat().field("id").is(manager.getUsername()) - .and().field("role").is(manager.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role can get site member for empty siteId") - public void getSiteMemberForEmptySiteId() throws Exception - { - SiteModel emptySite = new SiteModel(""); - - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); - restClient.withCoreAPI().usingSite(emptySite).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), emptySite.getId())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Manager role gets site member with Manager role and status code is OK (200)") - public void getSiteManagerMemberWithManagerRole() throws Exception - { - UserModel anotherManager = dataUser.createRandomTestUser(); - dataUser.addUserToSite(anotherManager, publicSiteModel, UserRole.SiteManager); - - restClient.authenticateUser(manager); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(anotherManager) - .assertThat().field("id").is(anotherManager.getUsername()) - .and().field("role").is(anotherManager.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Collaborator role gets site member with Manager role and status code is OK (200)") - public void getSiteManagerMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(collaborator); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(manager) - .assertThat().field("id").is(manager.getUsername()) - .and().field("role").is(manager.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Consumer role gets site member with Manager role and status code is OK (200)") - public void getSiteManagerMemberWithConsumerRole() throws Exception - { - restClient.authenticateUser(consumer); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(manager) - .assertThat().field("id").is(manager.getUsername()) - .and().field("role").is(manager.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Contributor role gets site member with Manager role and status code is OK (200)") - public void getSiteManagerMemberWithContributorRole() throws Exception - { - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(manager) - .assertThat().field("id").is(manager.getUsername()) - .and().field("role").is(manager.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Contributor role gets admin site member and status code is OK (200)") - public void getSiteAdminManagerMember() throws Exception - { - restClient.authenticateUser(contributor); - restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(adminUser) - .assertThat().field("id").is(adminUser.getUsername()) - .and().field("role").is(UserRole.SiteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Collaborator role gets site member with Contributor role and status code is OK (200)") - public void getSiteContributorMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(collaborator).withCoreAPI().usingSite(publicSiteModel).getSiteMember(contributor) - .assertThat().field("id").is(contributor.getUsername()) - .and().field("role").is(contributor.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Contributor role gets site member with Collaborator role and status code is OK (200)") - public void getSiteCollaboratorMemberWithContributorRole() throws Exception - { - restClient.authenticateUser(contributor).withCoreAPI().usingSite(publicSiteModel).getSiteMember(collaborator) - .assertThat().field("id").is(collaborator.getUsername()) - .and().field("role").is(collaborator.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Collaborator role gets admin role and status code is OK (200)") - public void getAdminWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(collaborator).withCoreAPI().usingSite(publicSiteModel).getSiteMember(adminUser) - .assertThat().field("id").is(adminUser.getUsername()) - .and().field("role").is(UserRole.SiteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Collaborator role gets site member with Consumer role and status code is OK (200)") - public void getSiteConsumerMemberWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(collaborator).withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) - .assertThat().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets site member of private site and status code is OK (200)") - public void getSiteMemberOfPrivateSite() throws Exception - { - restClient.authenticateUser(manager).withCoreAPI().usingSite(privateSiteModel).getSiteMember(consumer) - .assertThat().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify not joined user is not is not able to get site member of private site and status code is 404") - public void regularUserIsNotAbleToGetSiteMemberOfPrivateSite() throws Exception { - UserModel regularUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(regularUser).withCoreAPI().usingSite(privateSiteModel).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), privateSiteModel.getTitle())); - } - - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify admin is not able to get from site a user that created a member request that was not accepted yet") - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - public void adminIsNotAbleToGetFromSiteANonExistingMember() throws Exception - { - UserModel newMember = dataUser.createRandomTestUser(); - restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); - - restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(newMember); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() - .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSiteModel.getTitle())) - .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets site creator and status code is OK (200)") - public void getSiteCreator() throws Exception - { - SiteModel newSiteModel = dataSite.usingUser(collaborator).createModeratedRandomSite(); - dataUser.addUserToSite(consumer, publicSiteModel, UserRole.SiteConsumer); - - restClient.authenticateUser(consumer).withCoreAPI().usingSite(newSiteModel).getSiteMember(collaborator) - .assertThat().field("id").is(collaborator.getUsername()) - .and().field("role").is(UserRole.SiteManager); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Consumer role can get site member using \"-me-\" in place of personId") - public void getSiteMemberOfPrivateSiteUsingMeForPersonId() throws Exception - { - UserModel meUser = new UserModel("-me-", "password"); - - restClient.authenticateUser(consumer).withCoreAPI().usingSite(privateSiteModel).getSiteMember(meUser) - .assertThat().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user gets site member of moderated site and status code is OK (200)") - public void getSiteMemberOfModeratedSite() throws Exception - { - restClient.authenticateUser(manager).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(consumer) - .assertThat().field("id").is(consumer.getUsername()) - .and().field("role").is(consumer.getUserRole()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify not joined user gets site member of moderated site and status code is OK (200)") - public void regularUserIsAbleToGetSiteMemberOfModeratedSite() throws Exception - { - UserModel regularUser = dataUser.createRandomTestUser(); - - restClient.authenticateUser(regularUser).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(consumer); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if get site member request with properties parameter returns status code 200 and parameter is applied") - public void getSiteMemberUsingPropertiesParameter() throws Exception - { - restClient.authenticateUser(manager) - .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteMember(consumer) - .assertThat().fieldsCount().is(1) - .and().field("id").isNotEmpty() - .and().field("role").isNull() - .and().field("person").isNull(); - restClient.assertStatusCodeIs(HttpStatus.OK); - } -} +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.exception.JsonToModelConversionException; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.exception.DataPreparationException; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +public class GetSiteMemberTests extends RestTest +{ + private UserModel adminUser; + private SiteModel publicSiteModel, moderatedSiteModel, privateSiteModel; + private ListUserWithRoles usersWithRoles; + private UserModel manager, consumer, collaborator, contributor; + + @BeforeClass(alwaysRun = true) + public void dataPreparation() throws DataPreparationException + { + adminUser = dataUser.getAdminUser(); + publicSiteModel = dataSite.usingUser(adminUser).createPublicRandomSite(); + moderatedSiteModel = dataSite.usingUser(adminUser).createModeratedRandomSite(); + privateSiteModel = dataSite.usingUser(adminUser).createPrivateRandomSite(); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSiteModel, UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, + UserRole.SiteContributor); + + consumer = dataUser.createRandomTestUser(); + manager = usersWithRoles.getOneUserWithRole(UserRole.SiteManager); + collaborator = usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator); + contributor = usersWithRoles.getOneUserWithRole(UserRole.SiteContributor); + + dataUser.addUserToSite(consumer, publicSiteModel, UserRole.SiteConsumer); + dataUser.addUserToSite(consumer, moderatedSiteModel, UserRole.SiteConsumer); + dataUser.addUserToSite(manager, moderatedSiteModel, UserRole.SiteManager); + dataUser.addUserToSite(consumer, privateSiteModel, UserRole.SiteConsumer); + dataUser.addUserToSite(manager, privateSiteModel, UserRole.SiteManager); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site member and status code is OK (200)") + public void getSiteMemberWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) + .assertThat().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Collaborator role gets site member and gets status code OK (200)") + public void getSiteMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) + .and().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Contributor role gets site member and gets status code OK (200)") + public void getSiteMemberWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) + .and().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Consumer role gets site member and gets status code OK (200)") + public void getSiteMemberWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) + .and().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with admin user gets site member and gets status code OK (200)") + public void getSiteMemberWithAdminUser() throws Exception + { + restClient.authenticateUser(adminUser); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) + .and().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site member call returns status code 401") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMember() throws JsonToModelConversionException, Exception + { + UserModel inexistentUser = new UserModel("inexistent user", "inexistent password"); + restClient.authenticateUser(inexistentUser); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Manager role doesn't get a site member of inexistent site and status code is Not Found (404)") + public void getSiteMemberOfInexistentSite() throws Exception + { + SiteModel invalidSite = new SiteModel("invalidSite"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(invalidSite).getSiteMember(consumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), invalidSite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Manager role doesn't get non site member of inexistent site and status code is Not Found (404)") + public void getSiteMemberForNonSiteMember() throws Exception + { + UserModel nonMember = dataUser.createRandomTestUser(); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(nonMember); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, nonMember.getUsername(), publicSiteModel.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Manager role doesn't get not existing site member and status code is Not Found (404)") + public void getSiteMemberForInexistentSiteMember() throws Exception + { + UserModel inexistentUser = new UserModel("inexistentUser", "password"); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(inexistentUser); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, inexistentUser.getUsername())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Manager role can get site member using \"-me-\" in place of personId") + public void getSiteMemberUsingMeForPersonId() throws Exception + { + UserModel meUser = new UserModel("-me-", "password"); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(meUser) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Manager role can get site member for empty siteId") + public void getSiteMemberForEmptySiteId() throws Exception + { + SiteModel emptySite = new SiteModel(""); + + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)); + restClient.withCoreAPI().usingSite(emptySite).getSiteMember(consumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), emptySite.getId())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Manager role gets site member with Manager role and status code is OK (200)") + public void getSiteManagerMemberWithManagerRole() throws Exception + { + UserModel anotherManager = dataUser.createRandomTestUser(); + dataUser.addUserToSite(anotherManager, publicSiteModel, UserRole.SiteManager); + + restClient.authenticateUser(manager); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(anotherManager) + .assertThat().field("id").is(anotherManager.getUsername()) + .and().field("role").is(anotherManager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Collaborator role gets site member with Manager role and status code is OK (200)") + public void getSiteManagerMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(collaborator); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(manager) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Consumer role gets site member with Manager role and status code is OK (200)") + public void getSiteManagerMemberWithConsumerRole() throws Exception + { + restClient.authenticateUser(consumer); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(manager) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Contributor role gets site member with Manager role and status code is OK (200)") + public void getSiteManagerMemberWithContributorRole() throws Exception + { + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(manager) + .assertThat().field("id").is(manager.getUsername()) + .and().field("role").is(manager.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Contributor role gets admin site member and status code is OK (200)") + public void getSiteAdminManagerMember() throws Exception + { + restClient.authenticateUser(contributor); + restClient.withCoreAPI().usingSite(publicSiteModel).getSiteMember(adminUser) + .assertThat().field("id").is(adminUser.getUsername()) + .and().field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Collaborator role gets site member with Contributor role and status code is OK (200)") + public void getSiteContributorMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(collaborator).withCoreAPI().usingSite(publicSiteModel).getSiteMember(contributor) + .assertThat().field("id").is(contributor.getUsername()) + .and().field("role").is(contributor.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Contributor role gets site member with Collaborator role and status code is OK (200)") + public void getSiteCollaboratorMemberWithContributorRole() throws Exception + { + restClient.authenticateUser(contributor).withCoreAPI().usingSite(publicSiteModel).getSiteMember(collaborator) + .assertThat().field("id").is(collaborator.getUsername()) + .and().field("role").is(collaborator.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Collaborator role gets admin role and status code is OK (200)") + public void getAdminWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(collaborator).withCoreAPI().usingSite(publicSiteModel).getSiteMember(adminUser) + .assertThat().field("id").is(adminUser.getUsername()) + .and().field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Collaborator role gets site member with Consumer role and status code is OK (200)") + public void getSiteConsumerMemberWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(collaborator).withCoreAPI().usingSite(publicSiteModel).getSiteMember(consumer) + .assertThat().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets site member of private site and status code is OK (200)") + public void getSiteMemberOfPrivateSite() throws Exception + { + restClient.authenticateUser(manager).withCoreAPI().usingSite(privateSiteModel).getSiteMember(consumer) + .assertThat().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify not joined user is not is not able to get site member of private site and status code is 404") + public void regularUserIsNotAbleToGetSiteMemberOfPrivateSite() throws Exception { + UserModel regularUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(regularUser).withCoreAPI().usingSite(privateSiteModel).getSiteMember(consumer); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, consumer.getUsername(), privateSiteModel.getTitle())); + } + + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify admin is not able to get from site a user that created a member request that was not accepted yet") + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + public void adminIsNotAbleToGetFromSiteANonExistingMember() throws Exception + { + UserModel newMember = dataUser.createRandomTestUser(); + restClient.authenticateUser(newMember).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSiteModel); + + restClient.authenticateUser(adminUser).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(newMember); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND).assertLastError() + .containsSummary(String.format(RestErrorModel.RELATIONSHIP_NOT_FOUND, newMember.getUsername(), moderatedSiteModel.getTitle())) + .containsErrorKey(RestErrorModel.RELATIONSHIP_NOT_FOUND_ERRORKEY) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets site creator and status code is OK (200)") + public void getSiteCreator() throws Exception + { + SiteModel newSiteModel = dataSite.usingUser(collaborator).createModeratedRandomSite(); + dataUser.addUserToSite(consumer, publicSiteModel, UserRole.SiteConsumer); + + restClient.authenticateUser(consumer).withCoreAPI().usingSite(newSiteModel).getSiteMember(collaborator) + .assertThat().field("id").is(collaborator.getUsername()) + .and().field("role").is(UserRole.SiteManager); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Consumer role can get site member using \"-me-\" in place of personId") + public void getSiteMemberOfPrivateSiteUsingMeForPersonId() throws Exception + { + UserModel meUser = new UserModel("-me-", "password"); + + restClient.authenticateUser(consumer).withCoreAPI().usingSite(privateSiteModel).getSiteMember(meUser) + .assertThat().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user gets site member of moderated site and status code is OK (200)") + public void getSiteMemberOfModeratedSite() throws Exception + { + restClient.authenticateUser(manager).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(consumer) + .assertThat().field("id").is(consumer.getUsername()) + .and().field("role").is(consumer.getUserRole()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = { TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify not joined user gets site member of moderated site and status code is OK (200)") + public void regularUserIsAbleToGetSiteMemberOfModeratedSite() throws Exception + { + UserModel regularUser = dataUser.createRandomTestUser(); + + restClient.authenticateUser(regularUser).withCoreAPI().usingSite(moderatedSiteModel).getSiteMember(consumer); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if get site member request with properties parameter returns status code 200 and parameter is applied") + public void getSiteMemberUsingPropertiesParameter() throws Exception + { + restClient.authenticateUser(manager) + .withCoreAPI().usingSite(publicSiteModel).usingParams("properties=id").getSiteMember(consumer) + .assertThat().fieldsCount().is(2) + .and().field("id").isNotEmpty() + .and().field("role").isNull() + .and().field("person").isNull(); + restClient.assertStatusCodeIs(HttpStatus.OK); + } +} diff --git a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java index 14353694f5..c3b3f5496b 100644 --- a/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java +++ b/packaging/tests/tas-restapi/src/test/java/org/alfresco/rest/sites/members/GetSiteMembersTests.java @@ -1,354 +1,354 @@ -package org.alfresco.rest.sites.members; - -import org.alfresco.rest.RestTest; -import org.alfresco.rest.model.RestErrorModel; -import org.alfresco.rest.model.RestSiteMemberModel; -import org.alfresco.rest.model.RestSiteMemberModelsCollection; -import org.alfresco.utility.constants.UserRole; -import org.alfresco.utility.data.DataUser.ListUserWithRoles; -import org.alfresco.utility.model.SiteModel; -import org.alfresco.utility.model.TestGroup; -import org.alfresco.utility.model.UserModel; -import org.alfresco.utility.testrail.ExecutionType; -import org.alfresco.utility.testrail.annotation.TestRail; -import org.springframework.http.HttpStatus; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * @author iulia.cojocea - */ -public class GetSiteMembersTests extends RestTest -{ - private SiteModel publicSite, privateSite, moderatedSite, moderatedSite2, moderatedSite3; - private RestSiteMemberModelsCollection siteMembers; - private ListUserWithRoles usersWithRoles, moderatedSiteUsers; - private UserModel regularUser, privateSiteConsumer, siteCreator; - private RestSiteMemberModel firstSiteMember, secondSiteMember, thirdSiteMember, fourthSiteMember; - - @BeforeClass(alwaysRun=true) - public void dataPreparation() throws Exception - { - siteCreator = dataUser.createRandomTestUser(); - regularUser = dataUser.createRandomTestUser(); - privateSiteConsumer = dataUser.createRandomTestUser(); - - publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); - privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); - moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - moderatedSite2 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - moderatedSite3 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); - - dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); - dataUser.addUserToSite(privateSiteConsumer, moderatedSite3, UserRole.SiteConsumer); - usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - moderatedSiteUsers = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); - - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).usingParams("properties=role,id").getSiteMembers(); - firstSiteMember = siteMembers.getEntries().get(0).onModel(); - secondSiteMember = siteMembers.getEntries().get(1).onModel(); - thirdSiteMember = siteMembers.getEntries().get(2).onModel(); - fourthSiteMember = siteMembers.getEntries().get(3).onModel(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Verify user with Manager role gets site members and gets status code OK (200)") - public void getSiteMembersWithManagerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) - .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) - .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Collaborator role gets site members and gets status code OK (200)") - public void getSiteMembersWithCollaboratorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) - .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() - .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() - .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Contributor role gets site members and gets status code OK (200)") - public void getSiteMembersWithContributorRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) - .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) - .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with Consumer role gets site members and gets status code OK (200)") - public void getSiteMembersWithConsumerRole() throws Exception - { - restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) - .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) - .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, - description = "Verify user with admin usere gets site members and gets status code OK (200)") - public void getSiteMembersWithAdminUser() throws Exception - { - restClient.authenticateUser(dataUser.getAdminUser()) - .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() - .and().entriesListContains("id", siteCreator.getUsername()) - .when().assertThat().entriesListContains("role", "SiteManager"); - restClient.assertStatusCodeIs(HttpStatus.OK); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) - @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, - description = "Failed authentication get site members call returns status code 401") -// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") - public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws Exception - { - UserModel userModel = dataUser.createRandomTestUser(); - userModel.setPassword("user wrong password"); - dataUser.addUserToSite(userModel, publicSite, UserRole.SiteManager); - restClient.authenticateUser(userModel) - .withCoreAPI().usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site members call returns status code 404 if siteId does not exist") - public void checkStatusCodeForNonExistentSiteId() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingSite("NonExistentSiteId").getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site members call returns status code 400 for invalid maxItems") - public void checkStatusCodeForInvalidMaxItems() throws Exception - { - restClient.authenticateUser(regularUser).withParams("maxItems=0") - .withCoreAPI().usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) - .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) - .stackTraceIs(RestErrorModel.STACKTRACE); - - restClient.withParams("maxItems=A") - .withCoreAPI().usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify get site members call returns status code 400 for invalid skipCount ") - public void checkStatusCodeForInvalidSkipCount() throws Exception - { - restClient.authenticateUser(regularUser).withParams("skipCount=A") - .withCoreAPI().usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); - - restClient.withParams("skipCount=-1") - .withCoreAPI().usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) - .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets public site members and status code is 200") - public void getPublicSiteMembers() throws Exception - { - siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() - .usingSite(publicSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) - .and().paginationField("count").is("5"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets moderated site members and status code is 200") - public void getModeratedSiteMembers() throws Exception - { - siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() - .usingSite(moderatedSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) - .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteContributor).getUsername()) - .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) - .and().paginationField("count").is("4"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user gets private site members if he is a member of that site and status code is 200") - public void getPrivateSiteMembersByASiteMember() throws Exception - { - siteMembers = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() - .usingSite(privateSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) - .and().entriesListContains("id", privateSiteConsumer.getUsername()) - .and().paginationField("count").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user doesn't get private site members if he is not a member of that site and status code is 404") - public void getPrivateSiteMembersByNotASiteMember() throws Exception - { - restClient.authenticateUser(regularUser).withCoreAPI() - .usingSite(privateSite).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) - .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user gets moderated site members after the adding of a new member and status code is 200") - public void getSiteMembersAfterAddingNewMember() throws Exception - { - siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) - .and().paginationField("count").is("1"); - - restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite2).addPerson(privateSiteConsumer); - - siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) - .and().entriesListContains("id", privateSiteConsumer.getUsername()) - .and().paginationField("count").is("2"); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets moderated site members with properties parameter applied and status code is 200") - public void getModeratedSiteMembersUsingPropertiesParameter() throws Exception - { - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).usingParams("properties=role,id").getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListCountIs(4) - .and().entriesListDoesNotContain("person") - .and().entriesListContains("role", UserRole.SiteManager.toString()) - .and().entriesListContains("id", siteCreator.getUsername()) - .and().entriesListContains("role", UserRole.SiteContributor.toString()) - .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteContributor).getUsername()) - .and().entriesListContains("role", UserRole.SiteCollaborator.toString()) - .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) - .and().entriesListContains("role", UserRole.SiteConsumer.toString()) - .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteConsumer).getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets moderated site members with skipCount parameter applied") - public void getModeratedSiteMembersUsingSkipCountParameter() throws Exception - { - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).usingParams("skipCount=2").getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().paginationField("count").is("2"); - siteMembers.assertThat().paginationField("skipCount").is("2"); - siteMembers.assertThat().entriesListDoesNotContain("id", firstSiteMember.getId()) - .and().entriesListDoesNotContain("id", secondSiteMember.getId()) - .and().entriesListContains("role", thirdSiteMember.getRole().toString()) - .and().entriesListContains("id", thirdSiteMember.getId()) - .and().entriesListContains("role", fourthSiteMember.getRole().toString()) - .and().entriesListContains("id", fourthSiteMember.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets moderated site members with high skipCount parameter applied") - public void getModeratedSiteMembersUsingHighSkipCountParameter() throws Exception - { - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).usingParams("skipCount=100").getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().paginationField("count").is("0"); - siteMembers.assertThat().paginationField("skipCount").is("100"); - siteMembers.assertThat().entriesListIsEmpty(); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets moderated site members with maxItems parameter applied and check all pagination fields") - public void getModeratedSiteMembersUsingMaxItemsParameter() throws Exception - { - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite).usingParams("maxItems=1").getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().paginationField("count").is("1"); - siteMembers.assertThat().paginationField("hasMoreItems").is("true"); - siteMembers.assertThat().paginationField("maxItems").is("1"); - siteMembers.assertThat().paginationField("totalItems").isNotPresent(); - siteMembers.assertThat().entriesListContains("id", firstSiteMember.getId()) - .and().entriesListContains("role", firstSiteMember.getRole().toString()) - .and().entriesListDoesNotContain("id", secondSiteMember.getId()) - .and().entriesListDoesNotContain("id", thirdSiteMember.getId()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if user gets moderated site members with member not joined yet and status code is 200") - public void getSiteMembersFromNotJoinedModeratedSite() throws Exception - { - UserModel userNotJoined = dataUser.createRandomTestUser(); - restClient.authenticateUser(userNotJoined).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); - restClient.assertStatusCodeIs(HttpStatus.CREATED); - - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite2).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) - .and().entriesListDoesNotContain("id", userNotJoined.getUsername()); - } - - @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) - @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, - description= "Verify if any user gets site members after the member was removed from site and status code is 200") - public void getSiteMembersAfterRemovingASiteMember() throws Exception - { - siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() - .usingSite(moderatedSite3).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListCountIs(2); - - restClient.withCoreAPI().usingSite(moderatedSite3).deleteSiteMember(privateSiteConsumer); - - siteMembers = restClient.withCoreAPI().usingSite(moderatedSite3).getSiteMembers(); - restClient.assertStatusCodeIs(HttpStatus.OK); - siteMembers.assertThat().entriesListCountIs(1) - .and().entriesListContains("role", UserRole.SiteManager.toString()) - .and().entriesListContains("id", siteCreator.getUsername()); - } -} +package org.alfresco.rest.sites.members; + +import org.alfresco.rest.RestTest; +import org.alfresco.rest.model.RestErrorModel; +import org.alfresco.rest.model.RestSiteMemberModel; +import org.alfresco.rest.model.RestSiteMemberModelsCollection; +import org.alfresco.utility.constants.UserRole; +import org.alfresco.utility.data.DataUser.ListUserWithRoles; +import org.alfresco.utility.model.SiteModel; +import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; +import org.alfresco.utility.testrail.ExecutionType; +import org.alfresco.utility.testrail.annotation.TestRail; +import org.springframework.http.HttpStatus; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +/** + * @author iulia.cojocea + */ +public class GetSiteMembersTests extends RestTest +{ + private SiteModel publicSite, privateSite, moderatedSite, moderatedSite2, moderatedSite3; + private RestSiteMemberModelsCollection siteMembers; + private ListUserWithRoles usersWithRoles, moderatedSiteUsers; + private UserModel regularUser, privateSiteConsumer, siteCreator; + private RestSiteMemberModel firstSiteMember, secondSiteMember, thirdSiteMember, fourthSiteMember; + + @BeforeClass(alwaysRun=true) + public void dataPreparation() throws Exception + { + siteCreator = dataUser.createRandomTestUser(); + regularUser = dataUser.createRandomTestUser(); + privateSiteConsumer = dataUser.createRandomTestUser(); + + publicSite = dataSite.usingUser(siteCreator).createPublicRandomSite(); + privateSite = dataSite.usingUser(siteCreator).createPrivateRandomSite(); + moderatedSite = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + moderatedSite2 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + moderatedSite3 = dataSite.usingUser(siteCreator).createModeratedRandomSite(); + + dataUser.addUserToSite(privateSiteConsumer, privateSite, UserRole.SiteConsumer); + dataUser.addUserToSite(privateSiteConsumer, moderatedSite3, UserRole.SiteConsumer); + usersWithRoles = dataUser.addUsersWithRolesToSite(publicSite,UserRole.SiteManager, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + moderatedSiteUsers = dataUser.addUsersWithRolesToSite(moderatedSite, UserRole.SiteCollaborator, UserRole.SiteConsumer, UserRole.SiteContributor); + + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).usingParams("properties=role,id").getSiteMembers(); + firstSiteMember = siteMembers.getEntries().get(0).onModel(); + secondSiteMember = siteMembers.getEntries().get(1).onModel(); + thirdSiteMember = siteMembers.getEntries().get(2).onModel(); + fourthSiteMember = siteMembers.getEntries().get(3).onModel(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Verify user with Manager role gets site members and gets status code OK (200)") + public void getSiteMembersWithManagerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteManager)) + .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUserRole().toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Collaborator role gets site members and gets status code OK (200)") + public void getSiteMembersWithCollaboratorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator)) + .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty().assertThat() + .entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()).and() + .entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUserRole().toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Contributor role gets site members and gets status code OK (200)") + public void getSiteMembersWithContributorRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteContributor)) + .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUserRole().toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with Consumer role gets site members and gets status code OK (200)") + public void getSiteMembersWithConsumerRole() throws Exception + { + restClient.authenticateUser(usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer)) + .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) + .and().entriesListContains("role", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUserRole().toString()); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.REGRESSION, + description = "Verify user with admin usere gets site members and gets status code OK (200)") + public void getSiteMembersWithAdminUser() throws Exception + { + restClient.authenticateUser(dataUser.getAdminUser()) + .withCoreAPI().usingSite(publicSite).getSiteMembers().assertThat().entriesListIsNotEmpty() + .and().entriesListContains("id", siteCreator.getUsername()) + .when().assertThat().entriesListContains("role", "SiteManager"); + restClient.assertStatusCodeIs(HttpStatus.OK); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.SANITY }) + @TestRail(section = {TestGroup.REST_API, TestGroup.SITES }, executionType = ExecutionType.SANITY, + description = "Failed authentication get site members call returns status code 401") +// @Bug(id="MNT-16904", description = "It fails only on environment with tenants") + public void unauthenticatedUserIsNotAuthorizedToRetrieveSiteMembers() throws Exception + { + UserModel userModel = dataUser.createRandomTestUser(); + userModel.setPassword("user wrong password"); + dataUser.addUserToSite(userModel, publicSite, UserRole.SiteManager); + restClient.authenticateUser(userModel) + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.UNAUTHORIZED); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site members call returns status code 404 if siteId does not exist") + public void checkStatusCodeForNonExistentSiteId() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingSite("NonExistentSiteId").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, "NonExistentSiteId")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site members call returns status code 400 for invalid maxItems") + public void checkStatusCodeForInvalidMaxItems() throws Exception + { + restClient.authenticateUser(regularUser).withParams("maxItems=0") + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .containsErrorKey(RestErrorModel.ONLY_POSITIVE_VALUES_MAXITEMS) + .descriptionURLIs(RestErrorModel.RESTAPIEXPLORER) + .stackTraceIs(RestErrorModel.STACKTRACE); + + restClient.withParams("maxItems=A") + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_MAXITEMS, "A")); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify get site members call returns status code 400 for invalid skipCount ") + public void checkStatusCodeForInvalidSkipCount() throws Exception + { + restClient.authenticateUser(regularUser).withParams("skipCount=A") + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(String.format(RestErrorModel.INVALID_SKIPCOUNT, "A")); + + restClient.withParams("skipCount=-1") + .withCoreAPI().usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.BAD_REQUEST) + .assertLastError().containsSummary(RestErrorModel.NEGATIVE_VALUES_SKIPCOUNT); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets public site members and status code is 200") + public void getPublicSiteMembers() throws Exception + { + siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() + .usingSite(publicSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteContributor).getUsername()) + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .and().entriesListContains("id", usersWithRoles.getOneUserWithRole(UserRole.SiteManager).getUsername()) + .and().paginationField("count").is("5"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site members and status code is 200") + public void getModeratedSiteMembers() throws Exception + { + siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() + .usingSite(moderatedSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) + .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteContributor).getUsername()) + .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteConsumer).getUsername()) + .and().paginationField("count").is("4"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user gets private site members if he is a member of that site and status code is 200") + public void getPrivateSiteMembersByASiteMember() throws Exception + { + siteMembers = restClient.authenticateUser(privateSiteConsumer).withCoreAPI() + .usingSite(privateSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) + .and().entriesListContains("id", privateSiteConsumer.getUsername()) + .and().paginationField("count").is("2"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user doesn't get private site members if he is not a member of that site and status code is 404") + public void getPrivateSiteMembersByNotASiteMember() throws Exception + { + restClient.authenticateUser(regularUser).withCoreAPI() + .usingSite(privateSite).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.NOT_FOUND) + .assertLastError().containsSummary(String.format(RestErrorModel.ENTITY_NOT_FOUND, privateSite.getTitle())); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user gets moderated site members after the adding of a new member and status code is 200") + public void getSiteMembersAfterAddingNewMember() throws Exception + { + siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) + .and().paginationField("count").is("1"); + + restClient.authenticateUser(siteCreator).withCoreAPI().usingSite(moderatedSite2).addPerson(privateSiteConsumer); + + siteMembers = restClient.authenticateUser(regularUser).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) + .and().entriesListContains("id", privateSiteConsumer.getUsername()) + .and().paginationField("count").is("2"); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site members with properties parameter applied and status code is 200") + public void getModeratedSiteMembersUsingPropertiesParameter() throws Exception + { + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).usingParams("properties=role,id").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(4) + .and().entriesListDoesNotContain("person") + .and().entriesListContains("role", UserRole.SiteManager.toString()) + .and().entriesListContains("id", siteCreator.getUsername()) + .and().entriesListContains("role", UserRole.SiteContributor.toString()) + .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteContributor).getUsername()) + .and().entriesListContains("role", UserRole.SiteCollaborator.toString()) + .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteCollaborator).getUsername()) + .and().entriesListContains("role", UserRole.SiteConsumer.toString()) + .and().entriesListContains("id", moderatedSiteUsers.getOneUserWithRole(UserRole.SiteConsumer).getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site members with skipCount parameter applied") + public void getModeratedSiteMembersUsingSkipCountParameter() throws Exception + { + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).usingParams("skipCount=2").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().paginationField("count").is("2"); + siteMembers.assertThat().paginationField("skipCount").is("2"); + siteMembers.assertThat().entriesListDoesNotContain("id", firstSiteMember.getId()) + .and().entriesListDoesNotContain("id", secondSiteMember.getId()) + .and().entriesListContains("role", thirdSiteMember.getRole().toString()) + .and().entriesListContains("id", thirdSiteMember.getId()) + .and().entriesListContains("role", fourthSiteMember.getRole().toString()) + .and().entriesListContains("id", fourthSiteMember.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site members with high skipCount parameter applied") + public void getModeratedSiteMembersUsingHighSkipCountParameter() throws Exception + { + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).usingParams("skipCount=100").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().paginationField("count").is("0"); + siteMembers.assertThat().paginationField("skipCount").is("100"); + siteMembers.assertThat().entriesListIsEmpty(); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets moderated site members with maxItems parameter applied and check all pagination fields") + public void getModeratedSiteMembersUsingMaxItemsParameter() throws Exception + { + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite).usingParams("maxItems=1").getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().paginationField("count").is("1"); + siteMembers.assertThat().paginationField("hasMoreItems").is("true"); + siteMembers.assertThat().paginationField("maxItems").is("1"); + siteMembers.assertThat().paginationField("totalItems").is("4"); + siteMembers.assertThat().entriesListContains("id", firstSiteMember.getId()) + .and().entriesListContains("role", firstSiteMember.getRole().toString()) + .and().entriesListDoesNotContain("id", secondSiteMember.getId()) + .and().entriesListDoesNotContain("id", thirdSiteMember.getId()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if user gets moderated site members with member not joined yet and status code is 200") + public void getSiteMembersFromNotJoinedModeratedSite() throws Exception + { + UserModel userNotJoined = dataUser.createRandomTestUser(); + restClient.authenticateUser(userNotJoined).withCoreAPI().usingAuthUser().addSiteMembershipRequest(moderatedSite2); + restClient.assertStatusCodeIs(HttpStatus.CREATED); + + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite2).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListContains("id", siteCreator.getUsername()) + .and().entriesListDoesNotContain("id", userNotJoined.getUsername()); + } + + @Test(groups = { TestGroup.REST_API, TestGroup.SITES, TestGroup.REGRESSION }) + @TestRail(section={TestGroup.REST_API, TestGroup.SITES}, executionType= ExecutionType.REGRESSION, + description= "Verify if any user gets site members after the member was removed from site and status code is 200") + public void getSiteMembersAfterRemovingASiteMember() throws Exception + { + siteMembers = restClient.authenticateUser(siteCreator).withCoreAPI() + .usingSite(moderatedSite3).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(2); + + restClient.withCoreAPI().usingSite(moderatedSite3).deleteSiteMember(privateSiteConsumer); + + siteMembers = restClient.withCoreAPI().usingSite(moderatedSite3).getSiteMembers(); + restClient.assertStatusCodeIs(HttpStatus.OK); + siteMembers.assertThat().entriesListCountIs(1) + .and().entriesListContains("role", UserRole.SiteManager.toString()) + .and().entriesListContains("id", siteCreator.getUsername()); + } +} diff --git a/packaging/war/pom.xml b/packaging/war/pom.xml index bb6473b035..735da32cd0 100644 --- a/packaging/war/pom.xml +++ b/packaging/war/pom.xml @@ -1,282 +1,282 @@ - - 4.0.0 - content-services-community - Alfresco Content Services Community WAR - war - - - org.alfresco - alfresco-community-repo-packaging - 8.300-SNAPSHOT - - - - local/development/workspace - ${buildNumber} - - community - - - - - org.alfresco - alfresco-repository - - - org.alfresco - alfresco-remote-api - - - org.alfresco - alfresco-trashcan-cleaner - - - org.alfresco.services - alfresco-messaging-repo - - - xalan - xalan - - - commons-logging - commons-logging - - - org.apache.avalon.framework - avalon-framework-api - 4.3.1 - - - org.apache.avalon.framework - avalon-framework-impl - 4.3.1 - - - org.alfresco - alfresco-log-sanitizer - - - - org.glassfish.jaxb - jaxb-runtime - 2.3.2 - - - javax.xml.soap - javax.xml.soap-api - 1.4.0 - - - - javax.servlet - javax.servlet-api - provided - - - - org.alfresco - alfresco-core - tests - test - - - org.alfresco - alfresco-repository - tests - test - - - org.alfresco - alfresco-remote-api - tests - test - - - - commons-lang - commons-lang - - - org.springframework - spring-test - test - - - org.mockito - mockito-core - test - - - org.apache.shale - shale-test - 1.0.5 - test - - - org.postgresql - postgresql - test - - - mysql - mysql-connector-java - test - - - - - alfresco - - - - src/main/resources - - alfresco/version.properties - - - - src/main/resources - - alfresco/version.properties - - true - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.4 - - - validate - - create - - - - - 8 - - - - maven-dependency-plugin - - - - fetch-log4j-config - prepare-package - - unpack - - - - - org.alfresco - alfresco-core - - - log*.properties - ${project.build.outputDirectory} - - - - - - - maven-war-plugin - 3.3.1 - - - - pre-exploded-war - - exploded - - prepare-package - - - - - - org.codehaus.mojo - license-maven-plugin - - false - Alfresco Software Limited - true - true - classpath://alfresco - ${licenseName} - - src - - - **/*.java - **/*.jsp - - - - - check-licenses - compile - - check-file-header - - - - - - org.alfresco - alfresco-license-headers - 1.0 - - - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 3.2.0 - - ${maven.build.sourceVersion} - - - - - maven-release-plugin - 2.5.3 - - - org.codehaus.mojo - license-maven-plugin - 1.13 - - - - - - - - - m2e - - - commons-logging - commons-logging - - runtime - - - mysql - mysql-connector-java - - - - - + + 4.0.0 + content-services-community + Alfresco Content Services Community WAR + war + + + org.alfresco + alfresco-community-repo-packaging + 8.300-SNAPSHOT + + + + local/development/workspace + ${buildNumber} + + community + + + + + org.alfresco + alfresco-repository + + + org.alfresco + alfresco-remote-api + + + org.alfresco + alfresco-trashcan-cleaner + + + org.alfresco.services + alfresco-messaging-repo + + + xalan + xalan + + + commons-logging + commons-logging + + + org.apache.avalon.framework + avalon-framework-api + 4.3.1 + + + org.apache.avalon.framework + avalon-framework-impl + 4.3.1 + + + org.alfresco + alfresco-log-sanitizer + + + + org.glassfish.jaxb + jaxb-runtime + 2.3.2 + + + javax.xml.soap + javax.xml.soap-api + 1.4.0 + + + + javax.servlet + javax.servlet-api + provided + + + + org.alfresco + alfresco-core + tests + test + + + org.alfresco + alfresco-repository + tests + test + + + org.alfresco + alfresco-remote-api + tests + test + + + + commons-lang + commons-lang + + + org.springframework + spring-test + test + + + org.mockito + mockito-core + test + + + org.apache.shale + shale-test + 1.0.5 + test + + + org.postgresql + postgresql + test + + + mysql + mysql-connector-java + test + + + + + alfresco + + + + src/main/resources + + alfresco/version.properties + + + + src/main/resources + + alfresco/version.properties + + true + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.4 + + + validate + + create + + + + + 8 + + + + maven-dependency-plugin + + + + fetch-log4j-config + prepare-package + + unpack + + + + + org.alfresco + alfresco-core + + + log*.properties + ${project.build.outputDirectory} + + + + + + + maven-war-plugin + 3.3.1 + + + + pre-exploded-war + + exploded + + prepare-package + + + + + + org.codehaus.mojo + license-maven-plugin + + false + Alfresco Software Limited + true + true + classpath://alfresco + ${licenseName} + + src + + + **/*.java + **/*.jsp + + + + + check-licenses + compile + + check-file-header + + + + + + org.alfresco + alfresco-license-headers + 1.0 + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${dependency.maven-jar-plugin.version} + + ${maven.build.sourceVersion} + + + + + maven-release-plugin + 2.5.3 + + + org.codehaus.mojo + license-maven-plugin + 1.13 + + + + + + + + + m2e + + + commons-logging + commons-logging + + runtime + + + mysql + mysql-connector-java + + + + + diff --git a/pom.xml b/pom.xml index 30b7aab63d..ffc4159a55 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,8 @@ + ${project.version} + 7 0 0 @@ -62,6 +64,7 @@ 2.8.2 4.5.12 2.12.0-alfresco-patched-20191004 + 3.2.0 3.2.0 1.3.1 @@ -120,23 +123,23 @@ org.alfresco alfresco-core - ${project.version} + ${dependency.alfresco-community-repo.version} org.alfresco alfresco-core - ${project.version} + ${dependency.alfresco-community-repo.version} tests org.alfresco alfresco-data-model - ${project.version} + ${dependency.alfresco-community-repo.version} org.alfresco alfresco-data-model - ${project.version} + ${dependency.alfresco-community-repo.version} tests @@ -147,23 +150,23 @@ org.alfresco alfresco-remote-api - ${project.version} + ${dependency.alfresco-community-repo.version} org.alfresco alfresco-remote-api - ${project.version} + ${dependency.alfresco-community-repo.version} tests org.alfresco alfresco-repository - ${project.version} + ${dependency.alfresco-community-repo.version} org.alfresco alfresco-repository - ${project.version} + ${dependency.alfresco-community-repo.version} tests @@ -578,6 +581,41 @@ test + + org.alfresco.tas + alfresco-community-repo-cmis-test + ${dependency.alfresco-community-repo.version} + tests + test + + + org.alfresco.tas + alfresco-community-repo-email-test + ${dependency.alfresco-community-repo.version} + tests + test + + + org.alfresco.tas + alfresco-community-repo-integration-test + ${dependency.alfresco-community-repo.version} + tests + test + + + org.alfresco.tas + alfresco-community-repo-restapi-test + ${dependency.alfresco-community-repo.version} + tests + test + + + org.alfresco.tas + alfresco-community-repo-webdav-test + ${dependency.alfresco-community-repo.version} + tests + test + org.alfresco.tas utility